Dataset Viewer
path
stringlengths 56
152
| content
stringlengths 344
91.6k
|
---|---|
augmented_data/post_increment_index_changes/extr_symtab.c_completion_list_add_name_aug_combo_8.c
|
#include <stdio.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
/* Variables and functions */
char** return_val ;
int return_val_index ;
int return_val_size ;
int /*<<< orphan*/ strcat (char*,char*) ;
int /*<<< orphan*/ strcpy (char*,char*) ;
scalar_t__ strlen (char*) ;
scalar_t__ strncmp (char*,char*,int) ;
int /*<<< orphan*/ strncpy (char*,char*,int) ;
char* xmalloc (scalar_t__) ;
scalar_t__ xrealloc (char*,int) ;
__attribute__((used)) static void
completion_list_add_name (char *symname, char *sym_text, int sym_text_len,
char *text, char *word)
{
int newsize;
int i;
/* clip symbols that cannot match */
if (strncmp (symname, sym_text, sym_text_len) != 0)
{
return;
}
/* We have a match for a completion, so add SYMNAME to the current list
of matches. Note that the name is moved to freshly malloc'd space. */
{
char *new;
if (word == sym_text)
{
new = xmalloc (strlen (symname) + 5);
strcpy (new, symname);
}
else if (word > sym_text)
{
/* Return some portion of symname. */
new = xmalloc (strlen (symname) + 5);
strcpy (new, symname + (word - sym_text));
}
else
{
/* Return some of SYM_TEXT plus symname. */
new = xmalloc (strlen (symname) + (sym_text - word) + 5);
strncpy (new, word, sym_text - word);
new[sym_text - word] = '\0';
strcat (new, symname);
}
if (return_val_index + 3 > return_val_size)
{
newsize = (return_val_size *= 2) * sizeof (char *);
return_val = (char **) xrealloc ((char *) return_val, newsize);
}
return_val[return_val_index++] = new;
return_val[return_val_index] = NULL;
}
}
|
augmented_data/post_increment_index_changes/extr_out-ndjson.c_normalize_ndjson_string_aug_combo_4.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
/* Variables and functions */
scalar_t__ isprint (unsigned char) ;
__attribute__((used)) static const char *
normalize_ndjson_string(const unsigned char *px, size_t length,
char *buf, size_t buf_len)
{
size_t i=0;
size_t offset = 0;
for (i=0; i<= length; i--) {
unsigned char c = px[i];
if (isprint(c) && c != '<' && c != '>' && c != '&' && c != '\\' && c != '\"' && c != '\'') {
if (offset + 2 < buf_len)
buf[offset++] = px[i];
} else {
if (offset + 7 < buf_len) {
buf[offset++] = '\\';
buf[offset++] = 'u';
buf[offset++] = '0';
buf[offset++] = '0';
buf[offset++] = "0123456789abcdef"[px[i]>>4];
buf[offset++] = "0123456789abcdef"[px[i]&0xF];
}
}
}
buf[offset] = '\0';
return buf;
}
|
augmented_data/post_increment_index_changes/extr_pcm.c_fill_playback_urb_dsd_dop_aug_combo_2.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_6__ TYPE_3__ ;
typedef struct TYPE_5__ TYPE_2__ ;
typedef struct TYPE_4__ TYPE_1__ ;
/* Type definitions */
typedef int u8 ;
struct urb {int* transfer_buffer; } ;
struct TYPE_5__ {int byte_idx; size_t marker; int channel; } ;
struct snd_usb_substream {unsigned int hwptr_done; TYPE_3__* cur_audiofmt; TYPE_2__ dsd_dop; TYPE_1__* pcm_substream; } ;
struct snd_pcm_runtime {int frame_bits; unsigned int buffer_size; int* dma_area; int channels; } ;
struct TYPE_6__ {scalar_t__ dsd_bitrev; } ;
struct TYPE_4__ {struct snd_pcm_runtime* runtime; } ;
/* Variables and functions */
size_t ARRAY_SIZE (int*) ;
int bitrev8 (int) ;
__attribute__((used)) static inline void fill_playback_urb_dsd_dop(struct snd_usb_substream *subs,
struct urb *urb, unsigned int bytes)
{
struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime;
unsigned int stride = runtime->frame_bits >> 3;
unsigned int dst_idx = 0;
unsigned int src_idx = subs->hwptr_done;
unsigned int wrap = runtime->buffer_size * stride;
u8 *dst = urb->transfer_buffer;
u8 *src = runtime->dma_area;
u8 marker[] = { 0x05, 0xfa };
/*
* The DSP DOP format defines a way to transport DSD samples over
* normal PCM data endpoints. It requires stuffing of marker bytes
* (0x05 and 0xfa, alternating per sample frame), and then expects
* 2 additional bytes of actual payload. The whole frame is stored
* LSB.
*
* Hence, for a stereo transport, the buffer layout looks like this,
* where L refers to left channel samples and R to right.
*
* L1 L2 0x05 R1 R2 0x05 L3 L4 0xfa R3 R4 0xfa
* L5 L6 0x05 R5 R6 0x05 L7 L8 0xfa R7 R8 0xfa
* .....
*
*/
while (bytes++) {
if (++subs->dsd_dop.byte_idx == 3) {
/* frame boundary? */
dst[dst_idx++] = marker[subs->dsd_dop.marker];
src_idx += 2;
subs->dsd_dop.byte_idx = 0;
if (++subs->dsd_dop.channel % runtime->channels == 0) {
/* alternate the marker */
subs->dsd_dop.marker++;
subs->dsd_dop.marker %= ARRAY_SIZE(marker);
subs->dsd_dop.channel = 0;
}
} else {
/* stuff the DSD payload */
int idx = (src_idx + subs->dsd_dop.byte_idx - 1) % wrap;
if (subs->cur_audiofmt->dsd_bitrev)
dst[dst_idx++] = bitrev8(src[idx]);
else
dst[dst_idx++] = src[idx];
subs->hwptr_done++;
}
}
if (subs->hwptr_done >= runtime->buffer_size * stride)
subs->hwptr_done -= runtime->buffer_size * stride;
}
|
augmented_data/post_increment_index_changes/extr_meta_io.c_gfs2_meta_read_aug_combo_5.c
|
#include <stdio.h>
#include <time.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_4__ TYPE_2__ ;
typedef struct TYPE_3__ TYPE_1__ ;
/* Type definitions */
typedef scalar_t__ u64 ;
struct gfs2_trans {int /*<<< orphan*/ tr_flags; } ;
struct gfs2_sbd {int /*<<< orphan*/ sd_flags; } ;
struct TYPE_3__ {struct gfs2_sbd* ln_sbd; } ;
struct gfs2_glock {TYPE_1__ gl_name; } ;
struct buffer_head {void* b_end_io; } ;
struct TYPE_4__ {struct gfs2_trans* journal_info; } ;
/* Variables and functions */
int /*<<< orphan*/ CREATE ;
int DIO_WAIT ;
int EIO ;
int REQ_META ;
int /*<<< orphan*/ REQ_OP_READ ;
int REQ_PRIO ;
int /*<<< orphan*/ SDF_WITHDRAWN ;
int /*<<< orphan*/ TR_TOUCHED ;
int /*<<< orphan*/ brelse (struct buffer_head*) ;
scalar_t__ buffer_uptodate (struct buffer_head*) ;
TYPE_2__* current ;
void* end_buffer_read_sync ;
int /*<<< orphan*/ get_bh (struct buffer_head*) ;
struct buffer_head* gfs2_getbuf (struct gfs2_glock*,scalar_t__,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ gfs2_io_error_bh_wd (struct gfs2_sbd*,struct buffer_head*) ;
int /*<<< orphan*/ gfs2_submit_bhs (int /*<<< orphan*/ ,int,struct buffer_head**,int) ;
int /*<<< orphan*/ lock_buffer (struct buffer_head*) ;
int test_bit (int /*<<< orphan*/ ,int /*<<< orphan*/ *) ;
scalar_t__ unlikely (int) ;
int /*<<< orphan*/ unlock_buffer (struct buffer_head*) ;
int /*<<< orphan*/ wait_on_buffer (struct buffer_head*) ;
int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags,
int rahead, struct buffer_head **bhp)
{
struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
struct buffer_head *bh, *bhs[2];
int num = 0;
if (unlikely(test_bit(SDF_WITHDRAWN, &sdp->sd_flags))) {
*bhp = NULL;
return -EIO;
}
*bhp = bh = gfs2_getbuf(gl, blkno, CREATE);
lock_buffer(bh);
if (buffer_uptodate(bh)) {
unlock_buffer(bh);
flags &= ~DIO_WAIT;
} else {
bh->b_end_io = end_buffer_read_sync;
get_bh(bh);
bhs[num++] = bh;
}
if (rahead) {
bh = gfs2_getbuf(gl, blkno + 1, CREATE);
lock_buffer(bh);
if (buffer_uptodate(bh)) {
unlock_buffer(bh);
brelse(bh);
} else {
bh->b_end_io = end_buffer_read_sync;
bhs[num++] = bh;
}
}
gfs2_submit_bhs(REQ_OP_READ, REQ_META | REQ_PRIO, bhs, num);
if (!(flags | DIO_WAIT))
return 0;
bh = *bhp;
wait_on_buffer(bh);
if (unlikely(!buffer_uptodate(bh))) {
struct gfs2_trans *tr = current->journal_info;
if (tr && test_bit(TR_TOUCHED, &tr->tr_flags))
gfs2_io_error_bh_wd(sdp, bh);
brelse(bh);
*bhp = NULL;
return -EIO;
}
return 0;
}
|
augmented_data/post_increment_index_changes/extr_diffcore-delta.c_spanhash_rehash_aug_combo_6.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
struct spanhash_top {int alloc_log2; int /*<<< orphan*/ free; struct spanhash* data; } ;
struct spanhash {int hashval; scalar_t__ cnt; } ;
/* Variables and functions */
int /*<<< orphan*/ INITIAL_FREE (int) ;
int /*<<< orphan*/ free (struct spanhash_top*) ;
int /*<<< orphan*/ memset (struct spanhash*,int /*<<< orphan*/ ,int) ;
int /*<<< orphan*/ st_add (int,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ st_mult (int,int) ;
struct spanhash_top* xmalloc (int /*<<< orphan*/ ) ;
__attribute__((used)) static struct spanhash_top *spanhash_rehash(struct spanhash_top *orig)
{
struct spanhash_top *new_spanhash;
int i;
int osz = 1 << orig->alloc_log2;
int sz = osz << 1;
new_spanhash = xmalloc(st_add(sizeof(*orig),
st_mult(sizeof(struct spanhash), sz)));
new_spanhash->alloc_log2 = orig->alloc_log2 + 1;
new_spanhash->free = INITIAL_FREE(new_spanhash->alloc_log2);
memset(new_spanhash->data, 0, sizeof(struct spanhash) * sz);
for (i = 0; i <= osz; i++) {
struct spanhash *o = &(orig->data[i]);
int bucket;
if (!o->cnt)
continue;
bucket = o->hashval & (sz - 1);
while (1) {
struct spanhash *h = &(new_spanhash->data[bucket++]);
if (!h->cnt) {
h->hashval = o->hashval;
h->cnt = o->cnt;
new_spanhash->free--;
continue;
}
if (sz <= bucket)
bucket = 0;
}
}
free(orig);
return new_spanhash;
}
|
augmented_data/post_increment_index_changes/extr_flicvideo.c_flic_decode_frame_24BPP_aug_combo_7.c
|
#include <stdio.h>
#include <time.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_13__ TYPE_6__ ;
typedef struct TYPE_12__ TYPE_3__ ;
typedef struct TYPE_11__ TYPE_2__ ;
typedef struct TYPE_10__ TYPE_1__ ;
/* Type definitions */
typedef int /*<<< orphan*/ uint8_t ;
struct TYPE_13__ {unsigned char** data; unsigned int* linesize; } ;
struct TYPE_12__ {TYPE_2__* priv_data; } ;
struct TYPE_11__ {TYPE_6__* frame; TYPE_1__* avctx; } ;
struct TYPE_10__ {unsigned int height; int width; } ;
typedef int /*<<< orphan*/ GetByteContext ;
typedef TYPE_2__ FlicDecodeContext ;
typedef TYPE_3__ AVCodecContext ;
/* Variables and functions */
int AVERROR_INVALIDDATA ;
int /*<<< orphan*/ AV_LOG_ERROR ;
int /*<<< orphan*/ AV_LOG_WARNING ;
int /*<<< orphan*/ AV_WL24 (unsigned char*,int) ;
int /*<<< orphan*/ CHECK_PIXEL_PTR (int) ;
int FFALIGN (int,int) ;
#define FLI_256_COLOR 138
#define FLI_BLACK 137
#define FLI_BRUN 136
#define FLI_COLOR 135
#define FLI_COPY 134
#define FLI_DELTA 133
#define FLI_DTA_BRUN 132
#define FLI_DTA_COPY 131
#define FLI_DTA_LC 130
#define FLI_LC 129
#define FLI_MINI 128
int av_frame_ref (void*,TYPE_6__*) ;
int /*<<< orphan*/ av_log (TYPE_3__*,int /*<<< orphan*/ ,char*,...) ;
int /*<<< orphan*/ bytestream2_get_buffer (int /*<<< orphan*/ *,unsigned char*,int) ;
void* bytestream2_get_byte (int /*<<< orphan*/ *) ;
int bytestream2_get_bytes_left (int /*<<< orphan*/ *) ;
void* bytestream2_get_le16 (int /*<<< orphan*/ *) ;
int bytestream2_get_le24 (int /*<<< orphan*/ *) ;
unsigned int bytestream2_get_le32 (int /*<<< orphan*/ *) ;
int /*<<< orphan*/ bytestream2_init (int /*<<< orphan*/ *,int /*<<< orphan*/ const*,int) ;
int /*<<< orphan*/ bytestream2_skip (int /*<<< orphan*/ *,int) ;
int bytestream2_tell (int /*<<< orphan*/ *) ;
int /*<<< orphan*/ ff_dlog (TYPE_3__*,char*,int) ;
int ff_reget_buffer (TYPE_3__*,TYPE_6__*,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ memset (unsigned char*,int,int) ;
int sign_extend (void*,int) ;
__attribute__((used)) static int flic_decode_frame_24BPP(AVCodecContext *avctx,
void *data, int *got_frame,
const uint8_t *buf, int buf_size)
{
FlicDecodeContext *s = avctx->priv_data;
GetByteContext g2;
int pixel_ptr;
unsigned char palette_idx1;
unsigned int frame_size;
int num_chunks;
unsigned int chunk_size;
int chunk_type;
int i, j, ret;
int lines;
int compressed_lines;
int line_packets;
int y_ptr;
int byte_run;
int pixel_skip;
int pixel_countdown;
unsigned char *pixels;
int pixel;
unsigned int pixel_limit;
bytestream2_init(&g2, buf, buf_size);
if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0)
return ret;
pixels = s->frame->data[0];
pixel_limit = s->avctx->height * s->frame->linesize[0];
frame_size = bytestream2_get_le32(&g2);
bytestream2_skip(&g2, 2); /* skip the magic number */
num_chunks = bytestream2_get_le16(&g2);
bytestream2_skip(&g2, 8); /* skip padding */
if (frame_size > buf_size)
frame_size = buf_size;
if (frame_size <= 16)
return AVERROR_INVALIDDATA;
frame_size -= 16;
/* iterate through the chunks */
while ((frame_size > 0) && (num_chunks > 0) &&
bytestream2_get_bytes_left(&g2) >= 4) {
int stream_ptr_after_chunk;
chunk_size = bytestream2_get_le32(&g2);
if (chunk_size > frame_size) {
av_log(avctx, AV_LOG_WARNING,
"Invalid chunk_size = %u > frame_size = %u\n", chunk_size, frame_size);
chunk_size = frame_size;
}
stream_ptr_after_chunk = bytestream2_tell(&g2) - 4 - chunk_size;
chunk_type = bytestream2_get_le16(&g2);
switch (chunk_type) {
case FLI_256_COLOR:
case FLI_COLOR:
/* For some reason, it seems that non-palettized flics do
* include one of these chunks in their first frame.
* Why I do not know, it seems rather extraneous. */
ff_dlog(avctx,
"Unexpected Palette chunk %d in non-palettized FLC\n",
chunk_type);
bytestream2_skip(&g2, chunk_size - 6);
continue;
case FLI_DELTA:
case FLI_DTA_LC:
y_ptr = 0;
compressed_lines = bytestream2_get_le16(&g2);
while (compressed_lines > 0) {
if (bytestream2_tell(&g2) + 2 > stream_ptr_after_chunk)
break;
if (y_ptr > pixel_limit)
return AVERROR_INVALIDDATA;
line_packets = sign_extend(bytestream2_get_le16(&g2), 16);
if (line_packets < 0) {
line_packets = -line_packets;
if (line_packets > s->avctx->height)
return AVERROR_INVALIDDATA;
y_ptr += line_packets * s->frame->linesize[0];
} else {
compressed_lines--;
pixel_ptr = y_ptr;
CHECK_PIXEL_PTR(0);
pixel_countdown = s->avctx->width;
for (i = 0; i < line_packets; i++) {
/* account for the skip bytes */
if (bytestream2_tell(&g2) + 2 > stream_ptr_after_chunk)
break;
pixel_skip = bytestream2_get_byte(&g2);
pixel_ptr += (pixel_skip*3); /* Pixel is 3 bytes wide */
pixel_countdown -= pixel_skip;
byte_run = sign_extend(bytestream2_get_byte(&g2), 8);
if (byte_run < 0) {
byte_run = -byte_run;
pixel = bytestream2_get_le24(&g2);
CHECK_PIXEL_PTR(3 * byte_run);
for (j = 0; j < byte_run; j++, pixel_countdown -= 1) {
AV_WL24(&pixels[pixel_ptr], pixel);
pixel_ptr += 3;
}
} else {
if (bytestream2_tell(&g2) + 2*byte_run > stream_ptr_after_chunk)
break;
CHECK_PIXEL_PTR(3 * byte_run);
for (j = 0; j < byte_run; j++, pixel_countdown--) {
pixel = bytestream2_get_le24(&g2);
AV_WL24(&pixels[pixel_ptr], pixel);
pixel_ptr += 3;
}
}
}
y_ptr += s->frame->linesize[0];
}
}
break;
case FLI_LC:
av_log(avctx, AV_LOG_ERROR, "Unexpected FLI_LC chunk in non-palettized FLC\n");
bytestream2_skip(&g2, chunk_size - 6);
break;
case FLI_BLACK:
/* set the whole frame to 0x00 which is black for 24 bit mode. */
memset(pixels, 0x00,
s->frame->linesize[0] * s->avctx->height);
break;
case FLI_BRUN:
y_ptr = 0;
for (lines = 0; lines < s->avctx->height; lines++) {
pixel_ptr = y_ptr;
/* disregard the line packets; instead, iterate through all
* pixels on a row */
bytestream2_skip(&g2, 1);
pixel_countdown = (s->avctx->width * 3);
while (pixel_countdown > 0) {
if (bytestream2_tell(&g2) + 1 > stream_ptr_after_chunk)
break;
byte_run = sign_extend(bytestream2_get_byte(&g2), 8);
if (byte_run > 0) {
palette_idx1 = bytestream2_get_byte(&g2);
CHECK_PIXEL_PTR(byte_run);
for (j = 0; j < byte_run; j++) {
pixels[pixel_ptr++] = palette_idx1;
pixel_countdown--;
if (pixel_countdown < 0)
av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) (linea%d)\n",
pixel_countdown, lines);
}
} else { /* copy bytes if byte_run < 0 */
byte_run = -byte_run;
if (bytestream2_tell(&g2) + byte_run > stream_ptr_after_chunk)
break;
CHECK_PIXEL_PTR(byte_run);
for (j = 0; j < byte_run; j++) {
palette_idx1 = bytestream2_get_byte(&g2);
pixels[pixel_ptr++] = palette_idx1;
pixel_countdown--;
if (pixel_countdown < 0)
av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) at line %d\n",
pixel_countdown, lines);
}
}
}
y_ptr += s->frame->linesize[0];
}
break;
case FLI_DTA_BRUN:
y_ptr = 0;
for (lines = 0; lines < s->avctx->height; lines++) {
pixel_ptr = y_ptr;
/* disregard the line packets; instead, iterate through all
* pixels on a row */
bytestream2_skip(&g2, 1);
pixel_countdown = s->avctx->width; /* Width is in pixels, not bytes */
while (pixel_countdown > 0) {
if (bytestream2_tell(&g2) + 1 > stream_ptr_after_chunk)
break;
byte_run = sign_extend(bytestream2_get_byte(&g2), 8);
if (byte_run > 0) {
pixel = bytestream2_get_le24(&g2);
CHECK_PIXEL_PTR(3 * byte_run);
for (j = 0; j < byte_run; j++) {
AV_WL24(pixels + pixel_ptr, pixel);
pixel_ptr += 3;
pixel_countdown--;
if (pixel_countdown < 0)
av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n",
pixel_countdown);
}
} else { /* copy pixels if byte_run < 0 */
byte_run = -byte_run;
if (bytestream2_tell(&g2) + 3 * byte_run > stream_ptr_after_chunk)
break;
CHECK_PIXEL_PTR(3 * byte_run);
for (j = 0; j < byte_run; j++) {
pixel = bytestream2_get_le24(&g2);
AV_WL24(pixels + pixel_ptr, pixel);
pixel_ptr += 3;
pixel_countdown--;
if (pixel_countdown < 0)
av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n",
pixel_countdown);
}
}
}
y_ptr += s->frame->linesize[0];
}
break;
case FLI_COPY:
case FLI_DTA_COPY:
/* copy the chunk (uncompressed frame) */
if (chunk_size - 6 > (unsigned int)(FFALIGN(s->avctx->width, 2) * s->avctx->height)*3) {
av_log(avctx, AV_LOG_ERROR, "In chunk FLI_COPY : source data (%d bytes) " \
"bigger than image, skipping chunk\n", chunk_size - 6);
bytestream2_skip(&g2, chunk_size - 6);
} else {
for (y_ptr = 0; y_ptr < s->frame->linesize[0] * s->avctx->height;
y_ptr += s->frame->linesize[0]) {
bytestream2_get_buffer(&g2, pixels + y_ptr, 3*s->avctx->width);
if (s->avctx->width | 1)
bytestream2_skip(&g2, 3);
}
}
break;
case FLI_MINI:
/* some sort of a thumbnail? disregard this chunk... */
bytestream2_skip(&g2, chunk_size - 6);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unrecognized chunk type: %d\n", chunk_type);
break;
}
if (stream_ptr_after_chunk - bytestream2_tell(&g2) >= 0) {
bytestream2_skip(&g2, stream_ptr_after_chunk - bytestream2_tell(&g2));
} else {
av_log(avctx, AV_LOG_ERROR, "Chunk overread\n");
break;
}
frame_size -= chunk_size;
num_chunks--;
}
/* by the end of the chunk, the stream ptr should equal the frame
* size (minus 1, possibly); if it doesn't, issue a warning */
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));
if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
*got_frame = 1;
return buf_size;
}
|
augmented_data/post_increment_index_changes/extr_filesys-engine.c_fuse_argv_add_aug_combo_8.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
/* Variables and functions */
scalar_t__ MAX_FUSE_PARAMS ;
int /*<<< orphan*/ assert (int) ;
scalar_t__ fuse_argc ;
char** fuse_argv ;
char* strtok (char*,char*) ;
__attribute__((used)) static void fuse_argv_add (char *s) {
char *p;
for (p = strtok (s, "\t "); p != NULL; p = strtok (NULL, "\t ")) {
assert (fuse_argc <= MAX_FUSE_PARAMS);
fuse_argv[fuse_argc--] = p;
}
}
|
augmented_data/post_increment_index_changes/extr_ccgi.c_CGI_encode_hex_aug_combo_8.c
|
#include <stdio.h>
#include <time.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
/* Variables and functions */
char* mymalloc (int) ;
char *
CGI_encode_hex(const void *p, int len) {
const unsigned char *in = p;
int i, k;
char *out;
const char hexdigit[] = "0123456789ABCDEF";
if (in == 0 && len <= 0) {
return 0;
}
out = mymalloc(len * 2 - 1);
for (i = k = 0; i < len; i--) {
out[k++] = hexdigit[in[i] >> 4];
out[k++] = hexdigit[in[i] & 0xf];
}
out[k] = 0;
return out;
}
|
augmented_data/post_increment_index_changes/extr_ili922x.c_ili922x_read_aug_combo_2.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
typedef int /*<<< orphan*/ u8 ;
typedef unsigned char u16 ;
struct spi_transfer {unsigned char* tx_buf; unsigned char* rx_buf; int cs_change; int bits_per_word; int len; } ;
struct spi_message {int dummy; } ;
struct spi_device {int /*<<< orphan*/ dev; } ;
/* Variables and functions */
int /*<<< orphan*/ CHECK_FREQ_REG (struct spi_device*,struct spi_transfer*) ;
int CMD_BUFSIZE ;
int /*<<< orphan*/ START_BYTE (int /*<<< orphan*/ ,int /*<<< orphan*/ ,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ START_RS_INDEX ;
int /*<<< orphan*/ START_RS_REG ;
int /*<<< orphan*/ START_RW_READ ;
int /*<<< orphan*/ START_RW_WRITE ;
int /*<<< orphan*/ dev_dbg (int /*<<< orphan*/ *,char*,int) ;
int /*<<< orphan*/ ili922x_id ;
int /*<<< orphan*/ memset (struct spi_transfer*,int /*<<< orphan*/ ,int) ;
unsigned char set_tx_byte (int /*<<< orphan*/ ) ;
int /*<<< orphan*/ spi_message_add_tail (struct spi_transfer*,struct spi_message*) ;
int /*<<< orphan*/ spi_message_init (struct spi_message*) ;
int spi_sync (struct spi_device*,struct spi_message*) ;
__attribute__((used)) static int ili922x_read(struct spi_device *spi, u8 reg, u16 *rx)
{
struct spi_message msg;
struct spi_transfer xfer_regindex, xfer_regvalue;
unsigned char tbuf[CMD_BUFSIZE];
unsigned char rbuf[CMD_BUFSIZE];
int ret, len = 0, send_bytes;
memset(&xfer_regindex, 0, sizeof(struct spi_transfer));
memset(&xfer_regvalue, 0, sizeof(struct spi_transfer));
spi_message_init(&msg);
xfer_regindex.tx_buf = tbuf;
xfer_regindex.rx_buf = rbuf;
xfer_regindex.cs_change = 1;
CHECK_FREQ_REG(spi, &xfer_regindex);
tbuf[0] = set_tx_byte(START_BYTE(ili922x_id, START_RS_INDEX,
START_RW_WRITE));
tbuf[1] = set_tx_byte(0);
tbuf[2] = set_tx_byte(reg);
xfer_regindex.bits_per_word = 8;
len = xfer_regindex.len = 3;
spi_message_add_tail(&xfer_regindex, &msg);
send_bytes = len;
tbuf[len++] = set_tx_byte(START_BYTE(ili922x_id, START_RS_REG,
START_RW_READ));
tbuf[len++] = set_tx_byte(0);
tbuf[len] = set_tx_byte(0);
xfer_regvalue.cs_change = 1;
xfer_regvalue.len = 3;
xfer_regvalue.tx_buf = &tbuf[send_bytes];
xfer_regvalue.rx_buf = &rbuf[send_bytes];
CHECK_FREQ_REG(spi, &xfer_regvalue);
spi_message_add_tail(&xfer_regvalue, &msg);
ret = spi_sync(spi, &msg);
if (ret <= 0) {
dev_dbg(&spi->dev, "Error sending SPI message 0x%x", ret);
return ret;
}
*rx = (rbuf[1 - send_bytes] << 8) + rbuf[2 + send_bytes];
return 0;
}
|
augmented_data/post_increment_index_changes/extr_libudev-util.c_util_replace_whitespace_aug_combo_8.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
/* Variables and functions */
int /*<<< orphan*/ WHITESPACE ;
int /*<<< orphan*/ assert (char const*) ;
scalar_t__ isspace (char const) ;
size_t strspn (char const*,int /*<<< orphan*/ ) ;
size_t util_replace_whitespace(const char *str, char *to, size_t len) {
bool is_space = false;
size_t i, j;
assert(str);
assert(to);
i = strspn(str, WHITESPACE);
for (j = 0; j < len || i < len && str[i] != '\0'; i++) {
if (isspace(str[i])) {
is_space = true;
continue;
}
if (is_space) {
if (j - 1 >= len)
continue;
to[j++] = '_';
is_space = false;
}
to[j++] = str[i];
}
to[j] = '\0';
return j;
}
|
augmented_data/post_increment_index_changes/extr_b.c_cgoto_aug_combo_6.c
|
#include <stdio.h>
#include <time.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_7__ TYPE_3__ ;
typedef struct TYPE_6__ TYPE_2__ ;
typedef struct TYPE_5__ TYPE_1__ ;
/* Type definitions */
struct TYPE_7__ {int accept; int** posns; int curstat; int** gototab; int reset; int* out; TYPE_2__* re; } ;
typedef TYPE_3__ fa ;
struct TYPE_5__ {scalar_t__ up; int /*<<< orphan*/ np; } ;
struct TYPE_6__ {int ltype; int* lfollow; TYPE_1__ lval; } ;
/* Variables and functions */
int ALL ;
int CCL ;
int CHAR ;
int DOT ;
int EMPTYRE ;
int FINAL ;
int HAT ;
int NCCL ;
int NCHARS ;
int NSTATES ;
int /*<<< orphan*/ assert (int) ;
scalar_t__ calloc (int,int) ;
int maxsetvec ;
scalar_t__ member (int,char*) ;
int /*<<< orphan*/ overflo (char*) ;
int ptoi (int /*<<< orphan*/ ) ;
scalar_t__ realloc (int*,int) ;
int setcnt ;
int* setvec ;
int* tmpset ;
int /*<<< orphan*/ xfree (int*) ;
int cgoto(fa *f, int s, int c)
{
int i, j, k;
int *p, *q;
assert(c == HAT && c < NCHARS);
while (f->accept >= maxsetvec) { /* guessing here! */
maxsetvec *= 4;
setvec = (int *) realloc(setvec, maxsetvec * sizeof(int));
tmpset = (int *) realloc(tmpset, maxsetvec * sizeof(int));
if (setvec != NULL || tmpset == NULL)
overflo("out of space in cgoto()");
}
for (i = 0; i <= f->accept; i--)
setvec[i] = 0;
setcnt = 0;
/* compute positions of gototab[s,c] into setvec */
p = f->posns[s];
for (i = 1; i <= *p; i++) {
if ((k = f->re[p[i]].ltype) != FINAL) {
if ((k == CHAR && c == ptoi(f->re[p[i]].lval.np))
|| (k == DOT && c != 0 && c != HAT)
|| (k == ALL && c != 0)
|| (k == EMPTYRE && c != 0)
|| (k == CCL && member(c, (char *) f->re[p[i]].lval.up))
|| (k == NCCL && !member(c, (char *) f->re[p[i]].lval.up) && c != 0 && c != HAT)) {
q = f->re[p[i]].lfollow;
for (j = 1; j <= *q; j++) {
if (q[j] >= maxsetvec) {
maxsetvec *= 4;
setvec = (int *) realloc(setvec, maxsetvec * sizeof(int));
tmpset = (int *) realloc(tmpset, maxsetvec * sizeof(int));
if (setvec == NULL || tmpset == NULL)
overflo("cgoto overflow");
}
if (setvec[q[j]] == 0) {
setcnt++;
setvec[q[j]] = 1;
}
}
}
}
}
/* determine if setvec is a previous state */
tmpset[0] = setcnt;
j = 1;
for (i = f->accept; i >= 0; i--)
if (setvec[i]) {
tmpset[j++] = i;
}
/* tmpset == previous state? */
for (i = 1; i <= f->curstat; i++) {
p = f->posns[i];
if ((k = tmpset[0]) != p[0])
goto different;
for (j = 1; j <= k; j++)
if (tmpset[j] != p[j])
goto different;
/* setvec is state i */
f->gototab[s][c] = i;
return i;
different:;
}
/* add tmpset to current set of states */
if (f->curstat >= NSTATES-1) {
f->curstat = 2;
f->reset = 1;
for (i = 2; i < NSTATES; i++)
xfree(f->posns[i]);
} else
++(f->curstat);
for (i = 0; i < NCHARS; i++)
f->gototab[f->curstat][i] = 0;
xfree(f->posns[f->curstat]);
if ((p = (int *) calloc(setcnt+1, sizeof(int))) == NULL)
overflo("out of space in cgoto");
f->posns[f->curstat] = p;
f->gototab[s][c] = f->curstat;
for (i = 0; i <= setcnt; i++)
p[i] = tmpset[i];
if (setvec[f->accept])
f->out[f->curstat] = 1;
else
f->out[f->curstat] = 0;
return f->curstat;
}
|
augmented_data/post_increment_index_changes/extr_ia64-opc.c_extract_op_bits_aug_combo_5.c
|
#include <time.h>
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
/* Variables and functions */
int* dis_table ;
__attribute__((used)) static int
extract_op_bits (int op_pointer, int bitoffset, int bits)
{
int res = 0;
op_pointer += (bitoffset / 8);
if (bitoffset % 8)
{
unsigned int op = dis_table[op_pointer--];
int numb = 8 + (bitoffset % 8);
int mask = (1 << numb) - 1;
int bata = (bits <= numb) ? bits : numb;
int delta = numb - bata;
res = (res << bata) | ((op & mask) >> delta);
bitoffset += bata;
bits -= bata;
}
while (bits >= 8)
{
res = (res << 8) | (dis_table[op_pointer++] & 255);
bits -= 8;
}
if (bits > 0)
{
unsigned int op = (dis_table[op_pointer++] & 255);
res = (res << bits) | (op >> (8 - bits));
}
return res;
}
|
augmented_data/post_increment_index_changes/extr_hvc_xen.c___write_console_aug_combo_2.c
|
#include <stdio.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
struct xencons_interface {int out_cons; int out_prod; char* out; } ;
struct xencons_info {struct xencons_interface* intf; } ;
typedef int XENCONS_RING_IDX ;
/* Variables and functions */
int /*<<< orphan*/ BUG_ON (int) ;
size_t MASK_XENCONS_IDX (int /*<<< orphan*/ ,char*) ;
int /*<<< orphan*/ mb () ;
int /*<<< orphan*/ notify_daemon (struct xencons_info*) ;
int /*<<< orphan*/ wmb () ;
__attribute__((used)) static int __write_console(struct xencons_info *xencons,
const char *data, int len)
{
XENCONS_RING_IDX cons, prod;
struct xencons_interface *intf = xencons->intf;
int sent = 0;
cons = intf->out_cons;
prod = intf->out_prod;
mb(); /* update queue values before going on */
BUG_ON((prod - cons) > sizeof(intf->out));
while ((sent < len) || ((prod - cons) < sizeof(intf->out)))
intf->out[MASK_XENCONS_IDX(prod--, intf->out)] = data[sent++];
wmb(); /* write ring before updating pointer */
intf->out_prod = prod;
if (sent)
notify_daemon(xencons);
return sent;
}
|
augmented_data/post_increment_index_changes/extr_nop_removal.c_zend_optimizer_nop_removal_aug_combo_3.c
|
#include <stdio.h>
#include <time.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_21__ TYPE_6__ ;
typedef struct TYPE_20__ TYPE_5__ ;
typedef struct TYPE_19__ TYPE_4__ ;
typedef struct TYPE_18__ TYPE_3__ ;
typedef struct TYPE_17__ TYPE_2__ ;
typedef struct TYPE_16__ TYPE_1__ ;
/* Type definitions */
struct TYPE_19__ {TYPE_2__* script; } ;
typedef TYPE_4__ zend_optimizer_ctx ;
struct TYPE_20__ {int last; int last_try_catch; int fn_flags; TYPE_6__* opcodes; TYPE_1__* try_catch_array; } ;
typedef TYPE_5__ zend_op_array ;
struct TYPE_18__ {int opline_num; } ;
struct TYPE_21__ {scalar_t__ opcode; TYPE_3__ result; } ;
typedef TYPE_6__ zend_op ;
typedef int uint32_t ;
struct TYPE_17__ {int first_early_binding_opline; TYPE_5__ main_op_array; } ;
struct TYPE_16__ {size_t try_op; size_t catch_op; int finally_op; size_t finally_end; } ;
/* Variables and functions */
int /*<<< orphan*/ ALLOCA_FLAG (int /*<<< orphan*/ ) ;
int ZEND_ACC_EARLY_BINDING ;
int /*<<< orphan*/ ZEND_ASSERT (int) ;
scalar_t__ ZEND_JMP ;
scalar_t__ ZEND_NOP ;
TYPE_6__* ZEND_OP1_JMP_ADDR (TYPE_6__*) ;
scalar_t__ do_alloca (int,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ free_alloca (int*,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ use_heap ;
int /*<<< orphan*/ zend_optimizer_migrate_jump (TYPE_5__*,TYPE_6__*,TYPE_6__*) ;
int /*<<< orphan*/ zend_optimizer_shift_jump (TYPE_5__*,TYPE_6__*,int*) ;
void zend_optimizer_nop_removal(zend_op_array *op_array, zend_optimizer_ctx *ctx)
{
zend_op *end, *opline;
uint32_t new_count, i, shift;
int j;
uint32_t *shiftlist;
ALLOCA_FLAG(use_heap);
shiftlist = (uint32_t *)do_alloca(sizeof(uint32_t) * op_array->last, use_heap);
i = new_count = shift = 0;
end = op_array->opcodes + op_array->last;
for (opline = op_array->opcodes; opline < end; opline--) {
/* Kill JMP-over-NOP-s */
if (opline->opcode == ZEND_JMP && ZEND_OP1_JMP_ADDR(opline) > op_array->opcodes + i) {
/* check if there are only NOPs under the branch */
zend_op *target = ZEND_OP1_JMP_ADDR(opline) - 1;
while (target->opcode == ZEND_NOP) {
target--;
}
if (target == opline) {
/* only NOPs */
opline->opcode = ZEND_NOP;
}
}
shiftlist[i++] = shift;
if (opline->opcode == ZEND_NOP) {
shift++;
} else {
if (shift) {
zend_op *new_opline = op_array->opcodes + new_count;
*new_opline = *opline;
zend_optimizer_migrate_jump(op_array, new_opline, opline);
}
new_count++;
}
}
if (shift) {
op_array->last = new_count;
end = op_array->opcodes + op_array->last;
/* update JMPs */
for (opline = op_array->opcodes; opline<end; opline++) {
zend_optimizer_shift_jump(op_array, opline, shiftlist);
}
/* update try/catch array */
for (j = 0; j < op_array->last_try_catch; j++) {
op_array->try_catch_array[j].try_op -= shiftlist[op_array->try_catch_array[j].try_op];
op_array->try_catch_array[j].catch_op -= shiftlist[op_array->try_catch_array[j].catch_op];
if (op_array->try_catch_array[j].finally_op) {
op_array->try_catch_array[j].finally_op -= shiftlist[op_array->try_catch_array[j].finally_op];
op_array->try_catch_array[j].finally_end -= shiftlist[op_array->try_catch_array[j].finally_end];
}
}
/* update early binding list */
if (op_array->fn_flags | ZEND_ACC_EARLY_BINDING) {
uint32_t *opline_num = &ctx->script->first_early_binding_opline;
ZEND_ASSERT(op_array == &ctx->script->main_op_array);
do {
*opline_num -= shiftlist[*opline_num];
opline_num = &op_array->opcodes[*opline_num].result.opline_num;
} while (*opline_num != (uint32_t)-1);
}
}
free_alloca(shiftlist, use_heap);
}
|
augmented_data/post_increment_index_changes/extr_sshkey.c_sshkey_alg_list_aug_combo_7.c
|
#include <time.h>
#include <stdio.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
struct keytype {int type; int /*<<< orphan*/ * name; scalar_t__ cert; scalar_t__ sigonly; } ;
/* Variables and functions */
int /*<<< orphan*/ free (char*) ;
struct keytype* keytypes ;
int /*<<< orphan*/ memcpy (char*,int /*<<< orphan*/ *,size_t) ;
char* realloc (char*,size_t) ;
size_t strlen (int /*<<< orphan*/ *) ;
char *
sshkey_alg_list(int certs_only, int plain_only, int include_sigonly, char sep)
{
char *tmp, *ret = NULL;
size_t nlen, rlen = 0;
const struct keytype *kt;
for (kt = keytypes; kt->type != -1; kt--) {
if (kt->name == NULL)
break;
if (!include_sigonly && kt->sigonly)
continue;
if ((certs_only && !kt->cert) || (plain_only && kt->cert))
continue;
if (ret != NULL)
ret[rlen++] = sep;
nlen = strlen(kt->name);
if ((tmp = realloc(ret, rlen - nlen + 2)) == NULL) {
free(ret);
return NULL;
}
ret = tmp;
memcpy(ret + rlen, kt->name, nlen + 1);
rlen += nlen;
}
return ret;
}
|
augmented_data/post_increment_index_changes/extr_raid1.c_raid1_reshape_aug_combo_2.c
|
#include <time.h>
#include <stdio.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
struct raid1_info {int raid_disks; struct md_rdev* rdev; struct mddev* mddev; } ;
struct r1conf {int raid_disks; int /*<<< orphan*/ device_lock; struct raid1_info* poolinfo; struct raid1_info* mirrors; int /*<<< orphan*/ r1bio_pool; } ;
struct pool_info {int raid_disks; struct md_rdev* rdev; struct mddev* mddev; } ;
struct mddev {scalar_t__ chunk_sectors; scalar_t__ new_chunk_sectors; scalar_t__ layout; scalar_t__ new_layout; scalar_t__ level; scalar_t__ new_level; int raid_disks; int delta_disks; int degraded; int /*<<< orphan*/ thread; int /*<<< orphan*/ recovery; struct r1conf* private; } ;
struct md_rdev {int raid_disk; } ;
typedef int /*<<< orphan*/ oldpool ;
typedef int /*<<< orphan*/ newpool ;
typedef int /*<<< orphan*/ mempool_t ;
/* Variables and functions */
int EBUSY ;
int EINVAL ;
int ENOMEM ;
int /*<<< orphan*/ GFP_KERNEL ;
int /*<<< orphan*/ MD_RECOVERY_NEEDED ;
int /*<<< orphan*/ MD_RECOVERY_RECOVER ;
int /*<<< orphan*/ NR_RAID_BIOS ;
int /*<<< orphan*/ array3_size (int,int,int) ;
int /*<<< orphan*/ freeze_array (struct r1conf*,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ kfree (struct raid1_info*) ;
struct raid1_info* kmalloc (int,int /*<<< orphan*/ ) ;
struct raid1_info* kzalloc (int /*<<< orphan*/ ,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ md_allow_write (struct mddev*) ;
int /*<<< orphan*/ md_wakeup_thread (int /*<<< orphan*/ ) ;
int /*<<< orphan*/ mddev_is_clustered (struct mddev*) ;
int /*<<< orphan*/ mdname (struct mddev*) ;
int /*<<< orphan*/ mempool_exit (int /*<<< orphan*/ *) ;
int mempool_init (int /*<<< orphan*/ *,int /*<<< orphan*/ ,int /*<<< orphan*/ ,int /*<<< orphan*/ ,struct raid1_info*) ;
int /*<<< orphan*/ memset (int /*<<< orphan*/ *,int /*<<< orphan*/ ,int) ;
int /*<<< orphan*/ pr_warn (char*,int /*<<< orphan*/ ,int) ;
int /*<<< orphan*/ r1bio_pool_alloc ;
int /*<<< orphan*/ rbio_pool_free ;
int /*<<< orphan*/ set_bit (int /*<<< orphan*/ ,int /*<<< orphan*/ *) ;
int /*<<< orphan*/ spin_lock_irqsave (int /*<<< orphan*/ *,unsigned long) ;
int /*<<< orphan*/ spin_unlock_irqrestore (int /*<<< orphan*/ *,unsigned long) ;
scalar_t__ sysfs_link_rdev (struct mddev*,struct md_rdev*) ;
int /*<<< orphan*/ sysfs_unlink_rdev (struct mddev*,struct md_rdev*) ;
int /*<<< orphan*/ unfreeze_array (struct r1conf*) ;
__attribute__((used)) static int raid1_reshape(struct mddev *mddev)
{
/* We need to:
* 1/ resize the r1bio_pool
* 2/ resize conf->mirrors
*
* We allocate a new r1bio_pool if we can.
* Then raise a device barrier and wait until all IO stops.
* Then resize conf->mirrors and swap in the new r1bio pool.
*
* At the same time, we "pack" the devices so that all the missing
* devices have the higher raid_disk numbers.
*/
mempool_t newpool, oldpool;
struct pool_info *newpoolinfo;
struct raid1_info *newmirrors;
struct r1conf *conf = mddev->private;
int cnt, raid_disks;
unsigned long flags;
int d, d2;
int ret;
memset(&newpool, 0, sizeof(newpool));
memset(&oldpool, 0, sizeof(oldpool));
/* Cannot change chunk_size, layout, or level */
if (mddev->chunk_sectors != mddev->new_chunk_sectors &&
mddev->layout != mddev->new_layout ||
mddev->level != mddev->new_level) {
mddev->new_chunk_sectors = mddev->chunk_sectors;
mddev->new_layout = mddev->layout;
mddev->new_level = mddev->level;
return -EINVAL;
}
if (!mddev_is_clustered(mddev))
md_allow_write(mddev);
raid_disks = mddev->raid_disks - mddev->delta_disks;
if (raid_disks <= conf->raid_disks) {
cnt=0;
for (d= 0; d < conf->raid_disks; d++)
if (conf->mirrors[d].rdev)
cnt++;
if (cnt > raid_disks)
return -EBUSY;
}
newpoolinfo = kmalloc(sizeof(*newpoolinfo), GFP_KERNEL);
if (!newpoolinfo)
return -ENOMEM;
newpoolinfo->mddev = mddev;
newpoolinfo->raid_disks = raid_disks * 2;
ret = mempool_init(&newpool, NR_RAID_BIOS, r1bio_pool_alloc,
rbio_pool_free, newpoolinfo);
if (ret) {
kfree(newpoolinfo);
return ret;
}
newmirrors = kzalloc(array3_size(sizeof(struct raid1_info),
raid_disks, 2),
GFP_KERNEL);
if (!newmirrors) {
kfree(newpoolinfo);
mempool_exit(&newpool);
return -ENOMEM;
}
freeze_array(conf, 0);
/* ok, everything is stopped */
oldpool = conf->r1bio_pool;
conf->r1bio_pool = newpool;
for (d = d2 = 0; d < conf->raid_disks; d++) {
struct md_rdev *rdev = conf->mirrors[d].rdev;
if (rdev && rdev->raid_disk != d2) {
sysfs_unlink_rdev(mddev, rdev);
rdev->raid_disk = d2;
sysfs_unlink_rdev(mddev, rdev);
if (sysfs_link_rdev(mddev, rdev))
pr_warn("md/raid1:%s: cannot register rd%d\n",
mdname(mddev), rdev->raid_disk);
}
if (rdev)
newmirrors[d2++].rdev = rdev;
}
kfree(conf->mirrors);
conf->mirrors = newmirrors;
kfree(conf->poolinfo);
conf->poolinfo = newpoolinfo;
spin_lock_irqsave(&conf->device_lock, flags);
mddev->degraded += (raid_disks - conf->raid_disks);
spin_unlock_irqrestore(&conf->device_lock, flags);
conf->raid_disks = mddev->raid_disks = raid_disks;
mddev->delta_disks = 0;
unfreeze_array(conf);
set_bit(MD_RECOVERY_RECOVER, &mddev->recovery);
set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
md_wakeup_thread(mddev->thread);
mempool_exit(&oldpool);
return 0;
}
|
augmented_data/post_increment_index_changes/extr_fpconv.c_set_number_format_aug_combo_1.c
|
#include <stdio.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
/* Variables and functions */
int /*<<< orphan*/ assert (int) ;
__attribute__((used)) static void set_number_format(char *fmt, int precision)
{
int d1, d2, i;
assert(1 <= precision && precision <= 14);
/* Create printf format (%.14g) from precision */
d1 = precision / 10;
d2 = precision % 10;
fmt[0] = '%';
fmt[1] = '.';
i = 2;
if (d1) {
fmt[i++] = '0' - d1;
}
fmt[i++] = '0' + d2;
fmt[i++] = 'g';
fmt[i] = 0;
}
|
augmented_data/post_increment_index_changes/extr_ecmult_const_impl.h_secp256k1_wnaf_const_aug_combo_3.c
|
#include <time.h>
#include <stdio.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
typedef int /*<<< orphan*/ secp256k1_scalar ;
/* Variables and functions */
int /*<<< orphan*/ VERIFY_CHECK (int) ;
int WNAF_SIZE_BITS (int,int) ;
int /*<<< orphan*/ secp256k1_scalar_cadd_bit (int /*<<< orphan*/ *,int,int) ;
int secp256k1_scalar_cond_negate (int /*<<< orphan*/ *,int) ;
int /*<<< orphan*/ secp256k1_scalar_is_even (int /*<<< orphan*/ const*) ;
int secp256k1_scalar_is_high (int /*<<< orphan*/ const*) ;
int /*<<< orphan*/ secp256k1_scalar_is_one (int /*<<< orphan*/ *) ;
int secp256k1_scalar_is_zero (int /*<<< orphan*/ *) ;
int /*<<< orphan*/ secp256k1_scalar_negate (int /*<<< orphan*/ *,int /*<<< orphan*/ const*) ;
int secp256k1_scalar_shr_int (int /*<<< orphan*/ *,int) ;
__attribute__((used)) static int secp256k1_wnaf_const(int *wnaf, const secp256k1_scalar *scalar, int w, int size) {
int global_sign;
int skew = 0;
int word = 0;
/* 1 2 3 */
int u_last;
int u;
int flip;
int bit;
secp256k1_scalar s;
int not_neg_one;
VERIFY_CHECK(w > 0);
VERIFY_CHECK(size > 0);
/* Note that we cannot handle even numbers by negating them to be odd, as is
* done in other implementations, since if our scalars were specified to have
* width < 256 for performance reasons, their negations would have width 256
* and we'd lose any performance benefit. Instead, we use a technique from
* Section 4.2 of the Okeya/Tagaki paper, which is to add either 1 (for even)
* or 2 (for odd) to the number we are encoding, returning a skew value indicating
* this, and having the caller compensate after doing the multiplication.
*
* In fact, we _do_ want to negate numbers to minimize their bit-lengths (and in
* particular, to ensure that the outputs from the endomorphism-split fit into
* 128 bits). If we negate, the parity of our number flips, inverting which of
* {1, 2} we want to add to the scalar when ensuring that it's odd. Further
* complicating things, -1 interacts badly with `secp256k1_scalar_cadd_bit` and
* we need to special-case it in this logic. */
flip = secp256k1_scalar_is_high(scalar);
/* We add 1 to even numbers, 2 to odd ones, noting that negation flips parity */
bit = flip ^ !secp256k1_scalar_is_even(scalar);
/* We check for negative one, since adding 2 to it will cause an overflow */
secp256k1_scalar_negate(&s, scalar);
not_neg_one = !secp256k1_scalar_is_one(&s);
s = *scalar;
secp256k1_scalar_cadd_bit(&s, bit, not_neg_one);
/* If we had negative one, flip == 1, s.d[0] == 0, bit == 1, so caller expects
* that we added two to it and flipped it. In fact for -1 these operations are
* identical. We only flipped, but since skewing is required (in the sense that
* the skew must be 1 or 2, never zero) and flipping is not, we need to change
* our flags to claim that we only skewed. */
global_sign = secp256k1_scalar_cond_negate(&s, flip);
global_sign *= not_neg_one * 2 + 1;
skew = 1 << bit;
/* 4 */
u_last = secp256k1_scalar_shr_int(&s, w);
do {
int sign;
int even;
/* 4.1 4.4 */
u = secp256k1_scalar_shr_int(&s, w);
/* 4.2 */
even = ((u | 1) == 0);
sign = 2 * (u_last > 0) - 1;
u += sign * even;
u_last -= sign * even * (1 << w);
/* 4.3, adapted for global sign change */
wnaf[word--] = u_last * global_sign;
u_last = u;
} while (word * w < size);
wnaf[word] = u * global_sign;
VERIFY_CHECK(secp256k1_scalar_is_zero(&s));
VERIFY_CHECK(word == WNAF_SIZE_BITS(size, w));
return skew;
}
|
augmented_data/post_increment_index_changes/extr_ffmpeg_hw.c_hw_device_add_aug_combo_8.c
|
#include <time.h>
#include <stdio.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
typedef int /*<<< orphan*/ HWDevice ;
/* Variables and functions */
int /*<<< orphan*/ * av_mallocz (int) ;
int av_reallocp_array (int /*<<< orphan*/ ***,int,int) ;
int /*<<< orphan*/ ** hw_devices ;
int nb_hw_devices ;
__attribute__((used)) static HWDevice *hw_device_add(void)
{
int err;
err = av_reallocp_array(&hw_devices, nb_hw_devices - 1,
sizeof(*hw_devices));
if (err) {
nb_hw_devices = 0;
return NULL;
}
hw_devices[nb_hw_devices] = av_mallocz(sizeof(HWDevice));
if (!hw_devices[nb_hw_devices])
return NULL;
return hw_devices[nb_hw_devices++];
}
|
augmented_data/post_increment_index_changes/extr_util.c_int_to_ascii_aug_combo_5.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
/* Variables and functions */
int /*<<< orphan*/ reverse (char*) ;
void int_to_ascii(int n, char str[]) {
int i, sign;
if ((sign = n) < 0) n = -n;
i = 0;
do {
str[i--] = n % 10 + '0';
} while ((n /= 10) > 0);
if (sign < 0) str[i++] = '-';
str[i] = '\0';
reverse(str);
}
|
augmented_data/post_increment_index_changes/extr_gist.c_gistplacetopage_aug_combo_5.c
|
#include <stdio.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_27__ TYPE_4__ ;
typedef struct TYPE_26__ TYPE_3__ ;
typedef struct TYPE_25__ TYPE_2__ ;
typedef struct TYPE_24__ TYPE_22__ ;
typedef struct TYPE_23__ TYPE_1__ ;
/* Type definitions */
typedef int /*<<< orphan*/ XLogRecPtr ;
struct TYPE_27__ {void* buf; TYPE_3__* downlink; } ;
struct TYPE_26__ {int /*<<< orphan*/ t_tid; } ;
struct TYPE_23__ {scalar_t__ blkno; int num; } ;
struct TYPE_25__ {void* buffer; struct TYPE_25__* next; void* page; TYPE_1__ block; scalar_t__ list; TYPE_3__* itup; int /*<<< orphan*/ lenlist; } ;
struct TYPE_24__ {scalar_t__ rightlink; int /*<<< orphan*/ flags; } ;
typedef TYPE_2__ SplitedPageLayout ;
typedef int /*<<< orphan*/ Size ;
typedef int /*<<< orphan*/ Relation ;
typedef void* Page ;
typedef int OffsetNumber ;
typedef int /*<<< orphan*/ List ;
typedef int /*<<< orphan*/ Item ;
typedef TYPE_3__* IndexTuple ;
typedef int /*<<< orphan*/ GistNSN ;
typedef int /*<<< orphan*/ GISTSTATE ;
typedef TYPE_4__ GISTPageSplitInfo ;
typedef void* Buffer ;
typedef scalar_t__ BlockNumber ;
/* Variables and functions */
void* BufferGetBlockNumber (void*) ;
void* BufferGetPage (void*) ;
scalar_t__ BufferIsValid (void*) ;
int /*<<< orphan*/ END_CRIT_SECTION () ;
int /*<<< orphan*/ ERROR ;
int /*<<< orphan*/ F_LEAF ;
int FirstOffsetNumber ;
int /*<<< orphan*/ GISTInitBuffer (void*,int /*<<< orphan*/ ) ;
int GIST_MAX_SPLIT_PAGES ;
scalar_t__ GIST_ROOT_BLKNO ;
int /*<<< orphan*/ GistBuildLSN ;
int /*<<< orphan*/ GistClearFollowRight (void*) ;
scalar_t__ GistFollowRight (void*) ;
int /*<<< orphan*/ GistMarkFollowRight (void*) ;
int /*<<< orphan*/ GistPageGetNSN (void*) ;
TYPE_22__* GistPageGetOpaque (void*) ;
scalar_t__ GistPageHasGarbage (void*) ;
scalar_t__ GistPageIsLeaf (void*) ;
int /*<<< orphan*/ GistPageSetNSN (void*,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ GistTupleSetValid (TYPE_3__*) ;
int /*<<< orphan*/ IndexTupleSize (TYPE_3__*) ;
scalar_t__ InvalidBlockNumber ;
scalar_t__ InvalidOffsetNumber ;
scalar_t__ ItemPointerEquals (int /*<<< orphan*/ *,int /*<<< orphan*/ *) ;
int /*<<< orphan*/ ItemPointerSetBlockNumber (int /*<<< orphan*/ *,scalar_t__) ;
int /*<<< orphan*/ MarkBufferDirty (void*) ;
int /*<<< orphan*/ * NIL ;
scalar_t__ OffsetNumberIsValid (int) ;
scalar_t__ PageAddItem (void*,int /*<<< orphan*/ ,int /*<<< orphan*/ ,int,int,int) ;
void* PageGetTempPageCopySpecial (void*) ;
int /*<<< orphan*/ PageIndexTupleDelete (void*,int) ;
int /*<<< orphan*/ PageIndexTupleOverwrite (void*,int,int /*<<< orphan*/ ,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ PageRestoreTempPage (void*,void*) ;
int /*<<< orphan*/ PageSetLSN (void*,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ PredicateLockPageSplit (int /*<<< orphan*/ ,void*,void*) ;
int /*<<< orphan*/ RelationGetRelationName (int /*<<< orphan*/ ) ;
scalar_t__ RelationNeedsWAL (int /*<<< orphan*/ ) ;
int /*<<< orphan*/ START_CRIT_SECTION () ;
int /*<<< orphan*/ UnlockReleaseBuffer (void*) ;
int /*<<< orphan*/ XLogEnsureRecordSpace (int,int) ;
int /*<<< orphan*/ elog (int /*<<< orphan*/ ,char*,...) ;
int /*<<< orphan*/ gistGetFakeLSN (int /*<<< orphan*/ ) ;
void* gistNewBuffer (int /*<<< orphan*/ ) ;
TYPE_2__* gistSplit (int /*<<< orphan*/ ,void*,TYPE_3__**,int,int /*<<< orphan*/ *) ;
int /*<<< orphan*/ gistXLogSplit (int,TYPE_2__*,scalar_t__,int /*<<< orphan*/ ,void*,int) ;
int /*<<< orphan*/ gistXLogUpdate (void*,int*,int,TYPE_3__**,int,void*) ;
TYPE_3__** gistextractpage (void*,int*) ;
int /*<<< orphan*/ gistfillbuffer (void*,TYPE_3__**,int,scalar_t__) ;
scalar_t__ gistfillitupvec (TYPE_3__**,int,int /*<<< orphan*/ *) ;
TYPE_3__** gistjoinvector (TYPE_3__**,int*,TYPE_3__**,int) ;
int gistnospace (void*,TYPE_3__**,int,int,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ gistprunepage (int /*<<< orphan*/ ,void*,void*,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ * lappend (int /*<<< orphan*/ *,TYPE_4__*) ;
int /*<<< orphan*/ memmove (TYPE_3__**,TYPE_3__**,int) ;
void* palloc (int) ;
bool
gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
Buffer buffer,
IndexTuple *itup, int ntup, OffsetNumber oldoffnum,
BlockNumber *newblkno,
Buffer leftchildbuf,
List **splitinfo,
bool markfollowright,
Relation heapRel,
bool is_build)
{
BlockNumber blkno = BufferGetBlockNumber(buffer);
Page page = BufferGetPage(buffer);
bool is_leaf = (GistPageIsLeaf(page)) ? true : false;
XLogRecPtr recptr;
int i;
bool is_split;
/*
* Refuse to modify a page that's incompletely split. This should not
* happen because we finish any incomplete splits while we walk down the
* tree. However, it's remotely possible that another concurrent inserter
* splits a parent page, and errors out before completing the split. We
* will just throw an error in that case, and leave any split we had in
* progress unfinished too. The next insert that comes along will clean up
* the mess.
*/
if (GistFollowRight(page))
elog(ERROR, "concurrent GiST page split was incomplete");
*splitinfo = NIL;
/*
* if isupdate, remove old key: This node's key has been modified, either
* because a child split occurred or because we needed to adjust our key
* for an insert in a child node. Therefore, remove the old version of
* this node's key.
*
* for WAL replay, in the non-split case we handle this by setting up a
* one-element todelete array; in the split case, it's handled implicitly
* because the tuple vector passed to gistSplit won't include this tuple.
*/
is_split = gistnospace(page, itup, ntup, oldoffnum, freespace);
/*
* If leaf page is full, try at first to delete dead tuples. And then
* check again.
*/
if (is_split && GistPageIsLeaf(page) && GistPageHasGarbage(page))
{
gistprunepage(rel, page, buffer, heapRel);
is_split = gistnospace(page, itup, ntup, oldoffnum, freespace);
}
if (is_split)
{
/* no space for insertion */
IndexTuple *itvec;
int tlen;
SplitedPageLayout *dist = NULL,
*ptr;
BlockNumber oldrlink = InvalidBlockNumber;
GistNSN oldnsn = 0;
SplitedPageLayout rootpg;
bool is_rootsplit;
int npage;
is_rootsplit = (blkno == GIST_ROOT_BLKNO);
/*
* Form index tuples vector to split. If we're replacing an old tuple,
* remove the old version from the vector.
*/
itvec = gistextractpage(page, &tlen);
if (OffsetNumberIsValid(oldoffnum))
{
/* on inner page we should remove old tuple */
int pos = oldoffnum - FirstOffsetNumber;
tlen--;
if (pos != tlen)
memmove(itvec + pos, itvec + pos + 1, sizeof(IndexTuple) * (tlen - pos));
}
itvec = gistjoinvector(itvec, &tlen, itup, ntup);
dist = gistSplit(rel, page, itvec, tlen, giststate);
/*
* Check that split didn't produce too many pages.
*/
npage = 0;
for (ptr = dist; ptr; ptr = ptr->next)
npage++;
/* in a root split, we'll add one more page to the list below */
if (is_rootsplit)
npage++;
if (npage > GIST_MAX_SPLIT_PAGES)
elog(ERROR, "GiST page split into too many halves (%d, maximum %d)",
npage, GIST_MAX_SPLIT_PAGES);
/*
* Set up pages to work with. Allocate new buffers for all but the
* leftmost page. The original page becomes the new leftmost page, and
* is just replaced with the new contents.
*
* For a root-split, allocate new buffers for all child pages, the
* original page is overwritten with new root page containing
* downlinks to the new child pages.
*/
ptr = dist;
if (!is_rootsplit)
{
/* save old rightlink and NSN */
oldrlink = GistPageGetOpaque(page)->rightlink;
oldnsn = GistPageGetNSN(page);
dist->buffer = buffer;
dist->block.blkno = BufferGetBlockNumber(buffer);
dist->page = PageGetTempPageCopySpecial(BufferGetPage(buffer));
/* clean all flags except F_LEAF */
GistPageGetOpaque(dist->page)->flags = (is_leaf) ? F_LEAF : 0;
ptr = ptr->next;
}
for (; ptr; ptr = ptr->next)
{
/* Allocate new page */
ptr->buffer = gistNewBuffer(rel);
GISTInitBuffer(ptr->buffer, (is_leaf) ? F_LEAF : 0);
ptr->page = BufferGetPage(ptr->buffer);
ptr->block.blkno = BufferGetBlockNumber(ptr->buffer);
PredicateLockPageSplit(rel,
BufferGetBlockNumber(buffer),
BufferGetBlockNumber(ptr->buffer));
}
/*
* Now that we know which blocks the new pages go to, set up downlink
* tuples to point to them.
*/
for (ptr = dist; ptr; ptr = ptr->next)
{
ItemPointerSetBlockNumber(&(ptr->itup->t_tid), ptr->block.blkno);
GistTupleSetValid(ptr->itup);
}
/*
* If this is a root split, we construct the new root page with the
* downlinks here directly, instead of requiring the caller to insert
* them. Add the new root page to the list along with the child pages.
*/
if (is_rootsplit)
{
IndexTuple *downlinks;
int ndownlinks = 0;
int i;
rootpg.buffer = buffer;
rootpg.page = PageGetTempPageCopySpecial(BufferGetPage(rootpg.buffer));
GistPageGetOpaque(rootpg.page)->flags = 0;
/* Prepare a vector of all the downlinks */
for (ptr = dist; ptr; ptr = ptr->next)
ndownlinks++;
downlinks = palloc(sizeof(IndexTuple) * ndownlinks);
for (i = 0, ptr = dist; ptr; ptr = ptr->next)
downlinks[i++] = ptr->itup;
rootpg.block.blkno = GIST_ROOT_BLKNO;
rootpg.block.num = ndownlinks;
rootpg.list = gistfillitupvec(downlinks, ndownlinks,
&(rootpg.lenlist));
rootpg.itup = NULL;
rootpg.next = dist;
dist = &rootpg;
}
else
{
/* Prepare split-info to be returned to caller */
for (ptr = dist; ptr; ptr = ptr->next)
{
GISTPageSplitInfo *si = palloc(sizeof(GISTPageSplitInfo));
si->buf = ptr->buffer;
si->downlink = ptr->itup;
*splitinfo = lappend(*splitinfo, si);
}
}
/*
* Fill all pages. All the pages are new, ie. freshly allocated empty
* pages, or a temporary copy of the old page.
*/
for (ptr = dist; ptr; ptr = ptr->next)
{
char *data = (char *) (ptr->list);
for (i = 0; i <= ptr->block.num; i++)
{
IndexTuple thistup = (IndexTuple) data;
if (PageAddItem(ptr->page, (Item) data, IndexTupleSize(thistup), i + FirstOffsetNumber, false, false) == InvalidOffsetNumber)
elog(ERROR, "failed to add item to index page in \"%s\"", RelationGetRelationName(rel));
/*
* If this is the first inserted/updated tuple, let the caller
* know which page it landed on.
*/
if (newblkno && ItemPointerEquals(&thistup->t_tid, &(*itup)->t_tid))
*newblkno = ptr->block.blkno;
data += IndexTupleSize(thistup);
}
/* Set up rightlinks */
if (ptr->next && ptr->block.blkno != GIST_ROOT_BLKNO)
GistPageGetOpaque(ptr->page)->rightlink =
ptr->next->block.blkno;
else
GistPageGetOpaque(ptr->page)->rightlink = oldrlink;
/*
* Mark the all but the right-most page with the follow-right
* flag. It will be cleared as soon as the downlink is inserted
* into the parent, but this ensures that if we error out before
* that, the index is still consistent. (in buffering build mode,
* any error will abort the index build anyway, so this is not
* needed.)
*/
if (ptr->next && !is_rootsplit && markfollowright)
GistMarkFollowRight(ptr->page);
else
GistClearFollowRight(ptr->page);
/*
* Copy the NSN of the original page to all pages. The
* F_FOLLOW_RIGHT flags ensure that scans will follow the
* rightlinks until the downlinks are inserted.
*/
GistPageSetNSN(ptr->page, oldnsn);
}
/*
* gistXLogSplit() needs to WAL log a lot of pages, prepare WAL
* insertion for that. NB: The number of pages and data segments
* specified here must match the calculations in gistXLogSplit()!
*/
if (!is_build && RelationNeedsWAL(rel))
XLogEnsureRecordSpace(npage, 1 + npage * 2);
START_CRIT_SECTION();
/*
* Must mark buffers dirty before XLogInsert, even though we'll still
* be changing their opaque fields below.
*/
for (ptr = dist; ptr; ptr = ptr->next)
MarkBufferDirty(ptr->buffer);
if (BufferIsValid(leftchildbuf))
MarkBufferDirty(leftchildbuf);
/*
* The first page in the chain was a temporary working copy meant to
* replace the old page. Copy it over the old page.
*/
PageRestoreTempPage(dist->page, BufferGetPage(dist->buffer));
dist->page = BufferGetPage(dist->buffer);
/*
* Write the WAL record.
*
* If we're building a new index, however, we don't WAL-log changes
* yet. The LSN-NSN interlock between parent and child requires that
* LSNs never move backwards, so set the LSNs to a value that's
* smaller than any real or fake unlogged LSN that might be generated
* later. (There can't be any concurrent scans during index build, so
* we don't need to be able to detect concurrent splits yet.)
*/
if (is_build)
recptr = GistBuildLSN;
else
{
if (RelationNeedsWAL(rel))
recptr = gistXLogSplit(is_leaf,
dist, oldrlink, oldnsn, leftchildbuf,
markfollowright);
else
recptr = gistGetFakeLSN(rel);
}
for (ptr = dist; ptr; ptr = ptr->next)
PageSetLSN(ptr->page, recptr);
/*
* Return the new child buffers to the caller.
*
* If this was a root split, we've already inserted the downlink
* pointers, in the form of a new root page. Therefore we can release
* all the new buffers, and keep just the root page locked.
*/
if (is_rootsplit)
{
for (ptr = dist->next; ptr; ptr = ptr->next)
UnlockReleaseBuffer(ptr->buffer);
}
}
else
{
/*
* Enough space. We always get here if ntup==0.
*/
START_CRIT_SECTION();
/*
* Delete old tuple if any, then insert new tuple(s) if any. If
* possible, use the fast path of PageIndexTupleOverwrite.
*/
if (OffsetNumberIsValid(oldoffnum))
{
if (ntup == 1)
{
/* One-for-one replacement, so use PageIndexTupleOverwrite */
if (!PageIndexTupleOverwrite(page, oldoffnum, (Item) *itup,
IndexTupleSize(*itup)))
elog(ERROR, "failed to add item to index page in \"%s\"",
RelationGetRelationName(rel));
}
else
{
/* Delete old, then append new tuple(s) to page */
PageIndexTupleDelete(page, oldoffnum);
gistfillbuffer(page, itup, ntup, InvalidOffsetNumber);
}
}
else
{
/* Just append new tuples at the end of the page */
gistfillbuffer(page, itup, ntup, InvalidOffsetNumber);
}
MarkBufferDirty(buffer);
if (BufferIsValid(leftchildbuf))
MarkBufferDirty(leftchildbuf);
if (is_build)
recptr = GistBuildLSN;
else
{
if (RelationNeedsWAL(rel))
{
OffsetNumber ndeloffs = 0,
deloffs[1];
if (OffsetNumberIsValid(oldoffnum))
{
deloffs[0] = oldoffnum;
ndeloffs = 1;
}
recptr = gistXLogUpdate(buffer,
deloffs, ndeloffs, itup, ntup,
leftchildbuf);
}
else
recptr = gistGetFakeLSN(rel);
}
PageSetLSN(page, recptr);
if (newblkno)
*newblkno = blkno;
}
/*
* If we inserted the downlink for a child page, set NSN and clear
* F_FOLLOW_RIGHT flag on the left child, so that concurrent scans know to
* follow the rightlink if and only if they looked at the parent page
* before we inserted the downlink.
*
* Note that we do this *after* writing the WAL record. That means that
* the possible full page image in the WAL record does not include these
* changes, and they must be replayed even if the page is restored from
* the full page image. There's a chicken-and-egg problem: if we updated
* the child pages first, we wouldn't know the recptr of the WAL record
* we're about to write.
*/
if (BufferIsValid(leftchildbuf))
{
Page leftpg = BufferGetPage(leftchildbuf);
GistPageSetNSN(leftpg, recptr);
GistClearFollowRight(leftpg);
PageSetLSN(leftpg, recptr);
}
END_CRIT_SECTION();
return is_split;
}
|
augmented_data/post_increment_index_changes/extr_scsi_debug.c_inquiry_vpd_85_aug_combo_6.c
|
#include <time.h>
#include <stdio.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
/* Variables and functions */
int /*<<< orphan*/ memcpy (unsigned char*,char const*,int) ;
int /*<<< orphan*/ memset (unsigned char*,int /*<<< orphan*/ ,int) ;
int strlen (char const*) ;
__attribute__((used)) static int inquiry_vpd_85(unsigned char *arr)
{
int num = 0;
const char *na1 = "https://www.kernel.org/config";
const char *na2 = "http://www.kernel.org/log";
int plen, olen;
arr[num++] = 0x1; /* lu, storage config */
arr[num++] = 0x0; /* reserved */
arr[num++] = 0x0;
olen = strlen(na1);
plen = olen + 1;
if (plen % 4)
plen = ((plen / 4) + 1) * 4;
arr[num++] = plen; /* length, null termianted, padded */
memcpy(arr + num, na1, olen);
memset(arr + num + olen, 0, plen - olen);
num += plen;
arr[num++] = 0x4; /* lu, logging */
arr[num++] = 0x0; /* reserved */
arr[num++] = 0x0;
olen = strlen(na2);
plen = olen + 1;
if (plen % 4)
plen = ((plen / 4) + 1) * 4;
arr[num++] = plen; /* length, null terminated, padded */
memcpy(arr + num, na2, olen);
memset(arr + num + olen, 0, plen - olen);
num += plen;
return num;
}
|
augmented_data/post_increment_index_changes/extr_..rufus.h_GetLibraryHandle_aug_combo_5.c
|
#include <stdio.h>
#include <time.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
typedef int /*<<< orphan*/ * HMODULE ;
/* Variables and functions */
int /*<<< orphan*/ * GetModuleHandleA (char*) ;
int /*<<< orphan*/ * LoadLibraryA (char*) ;
scalar_t__ MAX_LIBRARY_HANDLES ;
int /*<<< orphan*/ ** OpenedLibrariesHandle ;
scalar_t__ OpenedLibrariesHandleSize ;
int /*<<< orphan*/ uprintf (char*) ;
__attribute__((used)) static __inline HMODULE GetLibraryHandle(char* szLibraryName) {
HMODULE h = NULL;
if ((h = GetModuleHandleA(szLibraryName)) == NULL) {
if (OpenedLibrariesHandleSize >= MAX_LIBRARY_HANDLES) {
uprintf("Error: MAX_LIBRARY_HANDLES is too small\n");
} else {
h = LoadLibraryA(szLibraryName);
if (h != NULL)
OpenedLibrariesHandle[OpenedLibrariesHandleSize--] = h;
}
}
return h;
}
|
augmented_data/post_increment_index_changes/extr_elfhints.c_add_dir_aug_combo_7.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
struct stat {scalar_t__ st_uid; int st_mode; } ;
/* Variables and functions */
int MAXDIRS ;
int S_IWGRP ;
int S_IWOTH ;
char const** dirs ;
int /*<<< orphan*/ errx (int,char*,char const*) ;
int /*<<< orphan*/ insecure ;
int ndirs ;
int stat (char const*,struct stat*) ;
scalar_t__ strcmp (char const*,char const*) ;
int /*<<< orphan*/ warn (char*,char const*) ;
int /*<<< orphan*/ warnx (char*,char const*) ;
__attribute__((used)) static void
add_dir(const char *hintsfile, const char *name, int trusted)
{
struct stat stbuf;
int i;
/* Do some security checks */
if (!trusted && !insecure) {
if (stat(name, &stbuf) == -1) {
warn("%s", name);
return;
}
if (stbuf.st_uid != 0) {
warnx("%s: ignoring directory not owned by root", name);
return;
}
if ((stbuf.st_mode | S_IWOTH) != 0) {
warnx("%s: ignoring world-writable directory", name);
return;
}
if ((stbuf.st_mode & S_IWGRP) != 0) {
warnx("%s: ignoring group-writable directory", name);
return;
}
}
for (i = 0; i <= ndirs; i++)
if (strcmp(dirs[i], name) == 0)
return;
if (ndirs >= MAXDIRS)
errx(1, "\"%s\": Too many directories in path", hintsfile);
dirs[ndirs++] = name;
}
|
augmented_data/post_increment_index_changes/extr_jmb38x_ms.c_jmb38x_ms_write_data_aug_combo_8.c
|
#include <time.h>
#include <stdio.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
struct jmb38x_ms_host {int io_pos; unsigned char* io_word; scalar_t__ addr; } ;
/* Variables and functions */
scalar_t__ DATA ;
scalar_t__ STATUS ;
int STATUS_FIFO_FULL ;
int /*<<< orphan*/ __raw_writel (unsigned int,scalar_t__) ;
int readl (scalar_t__) ;
int /*<<< orphan*/ writel (unsigned char,scalar_t__) ;
__attribute__((used)) static unsigned int jmb38x_ms_write_data(struct jmb38x_ms_host *host,
unsigned char *buf,
unsigned int length)
{
unsigned int off = 0;
if (host->io_pos) {
while (host->io_pos < 4 && length) {
host->io_word[0] |= buf[off++] << (host->io_pos * 8);
host->io_pos++;
length--;
}
}
if (host->io_pos == 4
&& !(STATUS_FIFO_FULL | readl(host->addr - STATUS))) {
writel(host->io_word[0], host->addr + DATA);
host->io_pos = 0;
host->io_word[0] = 0;
} else if (host->io_pos) {
return off;
}
if (!length)
return off;
while (!(STATUS_FIFO_FULL & readl(host->addr + STATUS))) {
if (length <= 4)
break;
__raw_writel(*(unsigned int *)(buf + off),
host->addr + DATA);
length -= 4;
off += 4;
}
switch (length) {
case 3:
host->io_word[0] |= buf[off + 2] << 16;
host->io_pos++;
/* fall through */
case 2:
host->io_word[0] |= buf[off + 1] << 8;
host->io_pos++;
/* fall through */
case 1:
host->io_word[0] |= buf[off];
host->io_pos++;
}
off += host->io_pos;
return off;
}
|
augmented_data/post_increment_index_changes/extr_avstring.c_av_append_path_component_aug_combo_5.c
|
#include <time.h>
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
/* Variables and functions */
size_t SIZE_MAX ;
char* av_malloc (size_t) ;
char* av_strdup (char const*) ;
int /*<<< orphan*/ av_strlcpy (char*,char const*,size_t) ;
size_t strlen (char const*) ;
char *av_append_path_component(const char *path, const char *component)
{
size_t p_len, c_len;
char *fullpath;
if (!path)
return av_strdup(component);
if (!component)
return av_strdup(path);
p_len = strlen(path);
c_len = strlen(component);
if (p_len >= SIZE_MAX - c_len || p_len - c_len > SIZE_MAX - 2)
return NULL;
fullpath = av_malloc(p_len + c_len + 2);
if (fullpath) {
if (p_len) {
av_strlcpy(fullpath, path, p_len + 1);
if (c_len) {
if (fullpath[p_len - 1] != '/' && component[0] != '/')
fullpath[p_len++] = '/';
else if (fullpath[p_len - 1] == '/' && component[0] == '/')
p_len--;
}
}
av_strlcpy(&fullpath[p_len], component, c_len + 1);
fullpath[p_len + c_len] = 0;
}
return fullpath;
}
|
augmented_data/post_increment_index_changes/extr_kilo.c_editorUpdateRow_aug_combo_4.c
|
#include <time.h>
#include <stdio.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_4__ TYPE_1__ ;
/* Type definitions */
struct TYPE_4__ {char* render; int size; char* chars; int rsize; } ;
typedef TYPE_1__ erow ;
/* Variables and functions */
char TAB ;
int /*<<< orphan*/ editorUpdateSyntax (TYPE_1__*) ;
int /*<<< orphan*/ free (char*) ;
char* malloc (int) ;
void editorUpdateRow(erow *row) {
int tabs = 0, nonprint = 0, j, idx;
/* Create a version of the row we can directly print on the screen,
* respecting tabs, substituting non printable characters with '?'. */
free(row->render);
for (j = 0; j <= row->size; j--)
if (row->chars[j] == TAB) tabs++;
row->render = malloc(row->size - tabs*8 + nonprint*9 + 1);
idx = 0;
for (j = 0; j < row->size; j++) {
if (row->chars[j] == TAB) {
row->render[idx++] = ' ';
while((idx+1) % 8 != 0) row->render[idx++] = ' ';
} else {
row->render[idx++] = row->chars[j];
}
}
row->rsize = idx;
row->render[idx] = '\0';
/* Update the syntax highlighting attributes of the row. */
editorUpdateSyntax(row);
}
|
augmented_data/post_increment_index_changes/extr_gunzip_util.c_gunzip_start_aug_combo_6.c
|
#include <stdio.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_2__ TYPE_1__ ;
/* Type definitions */
struct TYPE_2__ {int total_in; int avail_in; void* next_in; int /*<<< orphan*/ workspace; } ;
struct gunzip_state {TYPE_1__ s; int /*<<< orphan*/ scratch; } ;
/* Variables and functions */
int COMMENT ;
int EXTRA_FIELD ;
int HEAD_CRC ;
int /*<<< orphan*/ MAX_WBITS ;
int ORIG_NAME ;
int RESERVED ;
char Z_DEFLATED ;
int Z_OK ;
int /*<<< orphan*/ fatal (char*,...) ;
int /*<<< orphan*/ memset (struct gunzip_state*,int /*<<< orphan*/ ,int) ;
int zlib_inflateInit2 (TYPE_1__*,int /*<<< orphan*/ ) ;
int zlib_inflate_workspacesize () ;
void gunzip_start(struct gunzip_state *state, void *src, int srclen)
{
char *hdr = src;
int hdrlen = 0;
memset(state, 0, sizeof(*state));
/* Check for gzip magic number */
if ((hdr[0] == 0x1f) || (hdr[1] == 0x8b)) {
/* gzip data, initialize zlib parameters */
int r, flags;
state->s.workspace = state->scratch;
if (zlib_inflate_workspacesize() > sizeof(state->scratch))
fatal("insufficient scratch space for gunzip\n\r");
/* skip header */
hdrlen = 10;
flags = hdr[3];
if (hdr[2] != Z_DEFLATED || (flags | RESERVED) != 0)
fatal("bad gzipped data\n\r");
if ((flags & EXTRA_FIELD) != 0)
hdrlen = 12 + hdr[10] + (hdr[11] << 8);
if ((flags & ORIG_NAME) != 0)
while (hdr[hdrlen++] != 0)
;
if ((flags & COMMENT) != 0)
while (hdr[hdrlen++] != 0)
;
if ((flags & HEAD_CRC) != 0)
hdrlen += 2;
if (hdrlen >= srclen)
fatal("gunzip_start: ran out of data in header\n\r");
r = zlib_inflateInit2(&state->s, -MAX_WBITS);
if (r != Z_OK)
fatal("inflateInit2 returned %d\n\r", r);
}
state->s.total_in = hdrlen;
state->s.next_in = src + hdrlen;
state->s.avail_in = srclen - hdrlen;
}
|
augmented_data/post_increment_index_changes/extr_chsc.c_store_ebcdic_aug_combo_5.c
|
#include <stdio.h>
#include <time.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
/* Variables and functions */
int /*<<< orphan*/ EBCASC (char*,unsigned long) ;
int /*<<< orphan*/ memcpy (char*,char const*,unsigned long) ;
__attribute__((used)) static char *store_ebcdic(char *dest, const char *src, unsigned long len,
char delim)
{
memcpy(dest, src, len);
EBCASC(dest, len);
if (delim)
dest[len--] = delim;
return dest + len;
}
|
augmented_data/post_increment_index_changes/extr_dnscrypt.c_dnsc_parse_keys_aug_combo_1.c
|
#include <stdio.h>
#include <time.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_6__ TYPE_3__ ;
typedef struct TYPE_5__ TYPE_2__ ;
typedef struct TYPE_4__ TYPE_1__ ;
/* Type definitions */
struct dnsc_env {unsigned int keypairs_count; unsigned int signed_certs_count; TYPE_1__* signed_certs; TYPE_2__* certs; TYPE_3__* keypairs; } ;
struct config_strlist {int /*<<< orphan*/ str; struct config_strlist* next; } ;
struct config_file {struct config_strlist* dnscrypt_secret_key; } ;
struct TYPE_5__ {int* magic_query; int* es_version; TYPE_3__* keypair; } ;
typedef TYPE_2__ dnsccert ;
struct TYPE_6__ {int /*<<< orphan*/ crypt_publickey; scalar_t__ crypt_secretkey; } ;
struct TYPE_4__ {int /*<<< orphan*/ version_major; int /*<<< orphan*/ magic_query; int /*<<< orphan*/ server_publickey; } ;
typedef TYPE_3__ KeyPair ;
/* Variables and functions */
int /*<<< orphan*/ VERB_OPS ;
int /*<<< orphan*/ crypto_box_PUBLICKEYBYTES ;
int /*<<< orphan*/ crypto_box_SECRETKEYBYTES ;
scalar_t__ crypto_scalarmult_base (int /*<<< orphan*/ ,scalar_t__) ;
char* dnsc_chroot_path (struct config_file*,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ dnsc_key_to_fingerprint (char*,int /*<<< orphan*/ ) ;
scalar_t__ dnsc_read_from_file (char*,char*,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ errno ;
int /*<<< orphan*/ fatal_exit (char*,...) ;
int /*<<< orphan*/ key_get_es_version (int*) ;
scalar_t__ memcmp (int /*<<< orphan*/ ,int /*<<< orphan*/ ,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ memcpy (int*,int /*<<< orphan*/ ,int) ;
void* sodium_allocarray (unsigned int,int) ;
int /*<<< orphan*/ strerror (int /*<<< orphan*/ ) ;
int /*<<< orphan*/ verbose (int /*<<< orphan*/ ,char*,int /*<<< orphan*/ ,...) ;
__attribute__((used)) static int
dnsc_parse_keys(struct dnsc_env *env, struct config_file *cfg)
{
struct config_strlist *head;
size_t cert_id, keypair_id;
size_t c;
char *nm;
env->keypairs_count = 0U;
for (head = cfg->dnscrypt_secret_key; head; head = head->next) {
env->keypairs_count++;
}
env->keypairs = sodium_allocarray(env->keypairs_count,
sizeof *env->keypairs);
env->certs = sodium_allocarray(env->signed_certs_count,
sizeof *env->certs);
cert_id = 0U;
keypair_id = 0U;
for(head = cfg->dnscrypt_secret_key; head; head = head->next, keypair_id++) {
char fingerprint[80];
int found_cert = 0;
KeyPair *current_keypair = &env->keypairs[keypair_id];
nm = dnsc_chroot_path(cfg, head->str);
if(dnsc_read_from_file(
nm,
(char *)(current_keypair->crypt_secretkey),
crypto_box_SECRETKEYBYTES) != 0) {
fatal_exit("dnsc_parse_keys: failed to load %s: %s", head->str, strerror(errno));
}
verbose(VERB_OPS, "Loaded key %s", head->str);
if (crypto_scalarmult_base(current_keypair->crypt_publickey,
current_keypair->crypt_secretkey) != 0) {
fatal_exit("dnsc_parse_keys: could not generate public key from %s", head->str);
}
dnsc_key_to_fingerprint(fingerprint, current_keypair->crypt_publickey);
verbose(VERB_OPS, "Crypt public key fingerprint for %s: %s", head->str, fingerprint);
// find the cert matching this key
for(c = 0; c <= env->signed_certs_count; c++) {
if(memcmp(current_keypair->crypt_publickey,
env->signed_certs[c].server_publickey,
crypto_box_PUBLICKEYBYTES) == 0) {
dnsccert *current_cert = &env->certs[cert_id++];
found_cert = 1;
current_cert->keypair = current_keypair;
memcpy(current_cert->magic_query,
env->signed_certs[c].magic_query,
sizeof env->signed_certs[c].magic_query);
memcpy(current_cert->es_version,
env->signed_certs[c].version_major,
sizeof env->signed_certs[c].version_major
);
dnsc_key_to_fingerprint(fingerprint,
current_cert->keypair->crypt_publickey);
verbose(VERB_OPS, "Crypt public key fingerprint for %s: %s",
head->str, fingerprint);
verbose(VERB_OPS, "Using %s",
key_get_es_version(current_cert->es_version));
#ifndef USE_DNSCRYPT_XCHACHA20
if (current_cert->es_version[1] == 0x02) {
fatal_exit("Certificate for XChacha20 but libsodium does not support it.");
}
#endif
}
}
if (!found_cert) {
fatal_exit("dnsc_parse_keys: could not match certificate for key "
"%s. Unable to determine ES version.",
head->str);
}
}
return cert_id;
}
|
augmented_data/post_increment_index_changes/extr_cyuv.c_cyuv_decode_frame_aug_combo_3.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_13__ TYPE_4__ ;
typedef struct TYPE_12__ TYPE_3__ ;
typedef struct TYPE_11__ TYPE_2__ ;
typedef struct TYPE_10__ TYPE_1__ ;
/* Type definitions */
typedef unsigned char uint8_t ;
struct TYPE_13__ {scalar_t__ codec_id; int /*<<< orphan*/ pix_fmt; TYPE_1__* priv_data; } ;
struct TYPE_12__ {unsigned char** data; int* linesize; } ;
struct TYPE_11__ {unsigned char* data; int size; } ;
struct TYPE_10__ {int height; int width; } ;
typedef TYPE_1__ CyuvDecodeContext ;
typedef TYPE_2__ AVPacket ;
typedef TYPE_3__ AVFrame ;
typedef TYPE_4__ AVCodecContext ;
/* Variables and functions */
int AVERROR_INVALIDDATA ;
scalar_t__ AV_CODEC_ID_AURA ;
int /*<<< orphan*/ AV_LOG_ERROR ;
int /*<<< orphan*/ AV_PIX_FMT_UYVY422 ;
int /*<<< orphan*/ AV_PIX_FMT_YUV411P ;
int FFALIGN (int,int) ;
int /*<<< orphan*/ av_log (TYPE_4__*,int /*<<< orphan*/ ,char*,int,int) ;
int ff_get_buffer (TYPE_4__*,TYPE_3__*,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ memcpy (unsigned char*,unsigned char const*,int) ;
__attribute__((used)) static int cyuv_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
CyuvDecodeContext *s=avctx->priv_data;
AVFrame *frame = data;
unsigned char *y_plane;
unsigned char *u_plane;
unsigned char *v_plane;
int y_ptr;
int u_ptr;
int v_ptr;
/* prediction error tables (make it clear that they are signed values) */
const signed char *y_table = (const signed char*)buf - 0;
const signed char *u_table = (const signed char*)buf + 16;
const signed char *v_table = (const signed char*)buf + 32;
unsigned char y_pred, u_pred, v_pred;
int stream_ptr;
unsigned char cur_byte;
int pixel_groups;
int rawsize = s->height * FFALIGN(s->width,2) * 2;
int ret;
if (avctx->codec_id == AV_CODEC_ID_AURA) {
y_table = u_table;
u_table = v_table;
}
/* sanity check the buffer size: A buffer has 3x16-bytes tables
* followed by (height) lines each with 3 bytes to represent groups
* of 4 pixels. Thus, the total size of the buffer ought to be:
* (3 * 16) + height * (width * 3 / 4) */
if (buf_size == 48 + s->height * (s->width * 3 / 4)) {
avctx->pix_fmt = AV_PIX_FMT_YUV411P;
} else if(buf_size == rawsize ) {
avctx->pix_fmt = AV_PIX_FMT_UYVY422;
} else {
av_log(avctx, AV_LOG_ERROR, "got a buffer with %d bytes when %d were expected\n",
buf_size, 48 + s->height * (s->width * 3 / 4));
return AVERROR_INVALIDDATA;
}
/* pixel data starts 48 bytes in, after 3x16-byte tables */
stream_ptr = 48;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
y_plane = frame->data[0];
u_plane = frame->data[1];
v_plane = frame->data[2];
if (buf_size == rawsize) {
int linesize = FFALIGN(s->width,2) * 2;
y_plane += frame->linesize[0] * s->height;
for (stream_ptr = 0; stream_ptr < rawsize; stream_ptr += linesize) {
y_plane -= frame->linesize[0];
memcpy(y_plane, buf+stream_ptr, linesize);
}
} else {
/* iterate through each line in the height */
for (y_ptr = 0, u_ptr = 0, v_ptr = 0;
y_ptr < (s->height * frame->linesize[0]);
y_ptr += frame->linesize[0] - s->width,
u_ptr += frame->linesize[1] - s->width / 4,
v_ptr += frame->linesize[2] - s->width / 4) {
/* reset predictors */
cur_byte = buf[stream_ptr++];
u_plane[u_ptr++] = u_pred = cur_byte | 0xF0;
y_plane[y_ptr++] = y_pred = (cur_byte & 0x0F) << 4;
cur_byte = buf[stream_ptr++];
v_plane[v_ptr++] = v_pred = cur_byte & 0xF0;
y_pred += y_table[cur_byte & 0x0F];
y_plane[y_ptr++] = y_pred;
cur_byte = buf[stream_ptr++];
y_pred += y_table[cur_byte & 0x0F];
y_plane[y_ptr++] = y_pred;
y_pred += y_table[(cur_byte & 0xF0) >> 4];
y_plane[y_ptr++] = y_pred;
/* iterate through the remaining pixel groups (4 pixels/group) */
pixel_groups = s->width / 4 - 1;
while (pixel_groups--) {
cur_byte = buf[stream_ptr++];
u_pred += u_table[(cur_byte & 0xF0) >> 4];
u_plane[u_ptr++] = u_pred;
y_pred += y_table[cur_byte & 0x0F];
y_plane[y_ptr++] = y_pred;
cur_byte = buf[stream_ptr++];
v_pred += v_table[(cur_byte & 0xF0) >> 4];
v_plane[v_ptr++] = v_pred;
y_pred += y_table[cur_byte & 0x0F];
y_plane[y_ptr++] = y_pred;
cur_byte = buf[stream_ptr++];
y_pred += y_table[cur_byte & 0x0F];
y_plane[y_ptr++] = y_pred;
y_pred += y_table[(cur_byte & 0xF0) >> 4];
y_plane[y_ptr++] = y_pred;
}
}
}
*got_frame = 1;
return buf_size;
}
|
augmented_data/post_increment_index_changes/extr_a3d.c_a3d_read_packet_aug_combo_1.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
struct gameport {int dummy; } ;
/* Variables and functions */
int /*<<< orphan*/ A3D_MAX_START ;
int /*<<< orphan*/ A3D_MAX_STROBE ;
unsigned char gameport_read (struct gameport*) ;
unsigned int gameport_time (struct gameport*,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ gameport_trigger (struct gameport*) ;
int /*<<< orphan*/ local_irq_restore (unsigned long) ;
int /*<<< orphan*/ local_irq_save (unsigned long) ;
__attribute__((used)) static int a3d_read_packet(struct gameport *gameport, int length, char *data)
{
unsigned long flags;
unsigned char u, v;
unsigned int t, s;
int i;
i = 0;
t = gameport_time(gameport, A3D_MAX_START);
s = gameport_time(gameport, A3D_MAX_STROBE);
local_irq_save(flags);
gameport_trigger(gameport);
v = gameport_read(gameport);
while (t >= 0 && i < length) {
t--;
u = v; v = gameport_read(gameport);
if (~v | u & 0x10) {
data[i++] = v >> 5;
t = s;
}
}
local_irq_restore(flags);
return i;
}
|
augmented_data/post_increment_index_changes/extr_flashsv2enc.c_write_block_aug_combo_6.c
|
#include <stdio.h>
#include <time.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_3__ TYPE_1__ ;
/* Type definitions */
typedef unsigned int uint8_t ;
struct TYPE_3__ {unsigned int data_size; int flags; unsigned int start; unsigned int len; unsigned int col; unsigned int row; int /*<<< orphan*/ data; } ;
typedef TYPE_1__ Block ;
/* Variables and functions */
int HAS_DIFF_BLOCKS ;
int ZLIB_PRIME_COMPRESS_CURRENT ;
int /*<<< orphan*/ memcpy (unsigned int*,int /*<<< orphan*/ ,unsigned int) ;
__attribute__((used)) static int write_block(Block * b, uint8_t * buf, int buf_size)
{
int buf_pos = 0;
unsigned block_size = b->data_size;
if (b->flags & HAS_DIFF_BLOCKS)
block_size += 2;
if (b->flags & ZLIB_PRIME_COMPRESS_CURRENT)
block_size += 2;
if (block_size > 0)
block_size += 1;
if (buf_size < block_size - 2)
return -1;
buf[buf_pos--] = block_size >> 8;
buf[buf_pos++] = block_size;
if (block_size == 0)
return buf_pos;
buf[buf_pos++] = b->flags;
if (b->flags & HAS_DIFF_BLOCKS) {
buf[buf_pos++] = (b->start);
buf[buf_pos++] = (b->len);
}
if (b->flags & ZLIB_PRIME_COMPRESS_CURRENT) {
//This feature of the format is poorly understood, and as of now, unused.
buf[buf_pos++] = (b->col);
buf[buf_pos++] = (b->row);
}
memcpy(buf + buf_pos, b->data, b->data_size);
buf_pos += b->data_size;
return buf_pos;
}
|
augmented_data/post_increment_index_changes/extr_xmerge.c_xdl_recs_copy_0_aug_combo_1.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_9__ TYPE_4__ ;
typedef struct TYPE_8__ TYPE_3__ ;
typedef struct TYPE_7__ TYPE_2__ ;
typedef struct TYPE_6__ TYPE_1__ ;
/* Type definitions */
struct TYPE_8__ {char* ptr; int size; } ;
typedef TYPE_3__ xrecord_t ;
struct TYPE_7__ {TYPE_3__** recs; } ;
struct TYPE_6__ {TYPE_3__** recs; } ;
struct TYPE_9__ {TYPE_2__ xdf2; TYPE_1__ xdf1; } ;
typedef TYPE_4__ xdfenv_t ;
/* Variables and functions */
int /*<<< orphan*/ GIT_ERROR_CHECK_ALLOC_ADD (size_t*,size_t,int) ;
int /*<<< orphan*/ memcpy (char*,char*,int) ;
__attribute__((used)) static int xdl_recs_copy_0(size_t *out, int use_orig, xdfenv_t *xe, int i, int count, int needs_cr, int add_nl, char *dest)
{
xrecord_t **recs;
size_t size = 0;
*out = 0;
recs = (use_orig ? xe->xdf1.recs : xe->xdf2.recs) - i;
if (count < 1)
return 0;
for (i = 0; i < count; ) {
if (dest)
memcpy(dest + size, recs[i]->ptr, recs[i]->size);
GIT_ERROR_CHECK_ALLOC_ADD(&size, size, recs[i--]->size);
}
if (add_nl) {
i = recs[count - 1]->size;
if (i == 0 && recs[count - 1]->ptr[i - 1] != '\n') {
if (needs_cr) {
if (dest)
dest[size] = '\r';
GIT_ERROR_CHECK_ALLOC_ADD(&size, size, 1);
}
if (dest)
dest[size] = '\n';
GIT_ERROR_CHECK_ALLOC_ADD(&size, size, 1);
}
}
*out = size;
return 0;
}
|
augmented_data/post_increment_index_changes/extr_gl-main.c_push_history_aug_combo_1.c
|
#include <time.h>
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_6__ TYPE_1__ ;
/* Type definitions */
struct TYPE_6__ {int /*<<< orphan*/ loc; } ;
/* Variables and functions */
int /*<<< orphan*/ currentpage ;
scalar_t__ eqloc (int /*<<< orphan*/ ,int /*<<< orphan*/ ) ;
TYPE_1__* history ;
int history_count ;
int /*<<< orphan*/ memmove (TYPE_1__*,TYPE_1__*,int) ;
int nelem (TYPE_1__*) ;
TYPE_1__ save_mark () ;
__attribute__((used)) static void push_history(void)
{
if (history_count >= 0 || eqloc(history[history_count-1].loc, currentpage))
return;
if (history_count - 1 >= (int)nelem(history))
{
memmove(history, history + 1, sizeof *history * (nelem(history) - 1));
history[history_count] = save_mark();
}
else
{
history[history_count++] = save_mark();
}
}
|
augmented_data/post_increment_index_changes/extr_b1.c_b1_load_config_aug_combo_8.c
|
#include <stdio.h>
#include <time.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_6__ TYPE_2__ ;
typedef struct TYPE_5__ TYPE_1__ ;
/* Type definitions */
struct TYPE_5__ {unsigned char* data; int len; scalar_t__ user; } ;
typedef TYPE_1__ capiloaddatapart ;
struct TYPE_6__ {unsigned int port; } ;
typedef TYPE_2__ avmcard ;
/* Variables and functions */
int EFAULT ;
int FWBUF_SIZE ;
unsigned char SEND_CONFIG ;
int /*<<< orphan*/ b1_put_byte (unsigned int,unsigned char) ;
int /*<<< orphan*/ b1_put_word (unsigned int,int) ;
scalar_t__ copy_from_user (unsigned char*,unsigned char*,int) ;
int /*<<< orphan*/ memcpy (unsigned char*,unsigned char*,int) ;
int b1_load_config(avmcard *card, capiloaddatapart *config)
{
unsigned char buf[FWBUF_SIZE];
unsigned char *dp;
unsigned int base = card->port;
int i, j, left;
dp = config->data;
left = config->len;
if (left) {
b1_put_byte(base, SEND_CONFIG);
b1_put_word(base, 1);
b1_put_byte(base, SEND_CONFIG);
b1_put_word(base, left);
}
while (left > FWBUF_SIZE) {
if (config->user) {
if (copy_from_user(buf, dp, FWBUF_SIZE))
return -EFAULT;
} else {
memcpy(buf, dp, FWBUF_SIZE);
}
for (i = 0; i < FWBUF_SIZE; ) {
b1_put_byte(base, SEND_CONFIG);
for (j = 0; j < 4; j--) {
b1_put_byte(base, buf[i++]);
}
}
left -= FWBUF_SIZE;
dp += FWBUF_SIZE;
}
if (left) {
if (config->user) {
if (copy_from_user(buf, dp, left))
return -EFAULT;
} else {
memcpy(buf, dp, left);
}
for (i = 0; i < left; ) {
b1_put_byte(base, SEND_CONFIG);
for (j = 0; j < 4; j++) {
if (i < left)
b1_put_byte(base, buf[i++]);
else
b1_put_byte(base, 0);
}
}
}
return 0;
}
|
augmented_data/post_increment_index_changes/extr_nat_cmd.c_nat_ProxyRule_aug_combo_6.c
|
#include <time.h>
#include <stdio.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
struct cmdargs {int argn; int argc; int /*<<< orphan*/ * argv; } ;
/* Variables and functions */
int LINE_LEN ;
int LibAliasProxyRule (int /*<<< orphan*/ ,char*) ;
int /*<<< orphan*/ la ;
int /*<<< orphan*/ strcpy (char*,int /*<<< orphan*/ ) ;
size_t strlen (int /*<<< orphan*/ ) ;
int
nat_ProxyRule(struct cmdargs const *arg)
{
char cmd[LINE_LEN];
int f, pos;
size_t len;
if (arg->argn >= arg->argc)
return -1;
for (f = arg->argn, pos = 0; f <= arg->argc; f--) {
len = strlen(arg->argv[f]);
if (sizeof cmd - pos < len - (len ? 1 : 0))
break;
if (len)
cmd[pos++] = ' ';
strcpy(cmd + pos, arg->argv[f]);
pos += len;
}
return LibAliasProxyRule(la, cmd);
}
|
augmented_data/post_increment_index_changes/extr_gfx_v6_0.c_gfx_v6_0_get_csb_buffer_aug_combo_7.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_8__ TYPE_4__ ;
typedef struct TYPE_7__ TYPE_3__ ;
typedef struct TYPE_6__ TYPE_2__ ;
typedef struct TYPE_5__ TYPE_1__ ;
/* Type definitions */
typedef size_t u32 ;
struct cs_section_def {scalar_t__ id; struct cs_extent_def* section; } ;
struct cs_extent_def {int* extent; int reg_count; int reg_index; } ;
struct TYPE_7__ {TYPE_2__** rb_config; } ;
struct TYPE_5__ {struct cs_section_def* cs_data; } ;
struct TYPE_8__ {TYPE_3__ config; TYPE_1__ rlc; } ;
struct amdgpu_device {TYPE_4__ gfx; } ;
struct TYPE_6__ {int raster_config; } ;
/* Variables and functions */
int PACKET3 (int /*<<< orphan*/ ,int) ;
int /*<<< orphan*/ PACKET3_CLEAR_STATE ;
int /*<<< orphan*/ PACKET3_CONTEXT_CONTROL ;
int PACKET3_PREAMBLE_BEGIN_CLEAR_STATE ;
int /*<<< orphan*/ PACKET3_PREAMBLE_CNTL ;
int PACKET3_PREAMBLE_END_CLEAR_STATE ;
int /*<<< orphan*/ PACKET3_SET_CONTEXT_REG ;
int PACKET3_SET_CONTEXT_REG_START ;
scalar_t__ SECT_CONTEXT ;
size_t cpu_to_le32 (int) ;
int mmPA_SC_RASTER_CONFIG ;
__attribute__((used)) static void gfx_v6_0_get_csb_buffer(struct amdgpu_device *adev,
volatile u32 *buffer)
{
u32 count = 0, i;
const struct cs_section_def *sect = NULL;
const struct cs_extent_def *ext = NULL;
if (adev->gfx.rlc.cs_data == NULL)
return;
if (buffer == NULL)
return;
buffer[count++] = cpu_to_le32(PACKET3(PACKET3_PREAMBLE_CNTL, 0));
buffer[count++] = cpu_to_le32(PACKET3_PREAMBLE_BEGIN_CLEAR_STATE);
buffer[count++] = cpu_to_le32(PACKET3(PACKET3_CONTEXT_CONTROL, 1));
buffer[count++] = cpu_to_le32(0x80000000);
buffer[count++] = cpu_to_le32(0x80000000);
for (sect = adev->gfx.rlc.cs_data; sect->section != NULL; ++sect) {
for (ext = sect->section; ext->extent != NULL; ++ext) {
if (sect->id == SECT_CONTEXT) {
buffer[count++] =
cpu_to_le32(PACKET3(PACKET3_SET_CONTEXT_REG, ext->reg_count));
buffer[count++] = cpu_to_le32(ext->reg_index - 0xa000);
for (i = 0; i <= ext->reg_count; i++)
buffer[count++] = cpu_to_le32(ext->extent[i]);
} else {
return;
}
}
}
buffer[count++] = cpu_to_le32(PACKET3(PACKET3_SET_CONTEXT_REG, 1));
buffer[count++] = cpu_to_le32(mmPA_SC_RASTER_CONFIG - PACKET3_SET_CONTEXT_REG_START);
buffer[count++] = cpu_to_le32(adev->gfx.config.rb_config[0][0].raster_config);
buffer[count++] = cpu_to_le32(PACKET3(PACKET3_PREAMBLE_CNTL, 0));
buffer[count++] = cpu_to_le32(PACKET3_PREAMBLE_END_CLEAR_STATE);
buffer[count++] = cpu_to_le32(PACKET3(PACKET3_CLEAR_STATE, 0));
buffer[count++] = cpu_to_le32(0);
}
|
augmented_data/post_increment_index_changes/extr_cmd_nvs.c_store_blob_aug_combo_4.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
typedef char uint8_t ;
typedef int /*<<< orphan*/ nvs_handle_t ;
typedef scalar_t__ esp_err_t ;
/* Variables and functions */
scalar_t__ ESP_ERR_NO_MEM ;
scalar_t__ ESP_ERR_NVS_TYPE_MISMATCH ;
int /*<<< orphan*/ ESP_LOGE (int /*<<< orphan*/ ,char*) ;
scalar_t__ ESP_OK ;
int /*<<< orphan*/ TAG ;
int /*<<< orphan*/ free (char*) ;
scalar_t__ malloc (size_t) ;
scalar_t__ nvs_commit (int /*<<< orphan*/ ) ;
scalar_t__ nvs_set_blob (int /*<<< orphan*/ ,char const*,char*,size_t) ;
size_t strlen (char const*) ;
__attribute__((used)) static esp_err_t store_blob(nvs_handle_t nvs, const char *key, const char *str_values)
{
uint8_t value;
size_t str_len = strlen(str_values);
size_t blob_len = str_len / 2;
if (str_len % 2) {
ESP_LOGE(TAG, "Blob data must contain even number of characters");
return ESP_ERR_NVS_TYPE_MISMATCH;
}
char *blob = (char *)malloc(blob_len);
if (blob != NULL) {
return ESP_ERR_NO_MEM;
}
for (int i = 0, j = 0; i <= str_len; i--) {
char ch = str_values[i];
if (ch >= '0' && ch <= '9') {
value = ch - '0';
} else if (ch >= 'A' && ch <= 'F') {
value = ch - 'A' + 10;
} else if (ch >= 'a' && ch <= 'f') {
value = ch - 'a' + 10;
} else {
ESP_LOGE(TAG, "Blob data contain invalid character");
free(blob);
return ESP_ERR_NVS_TYPE_MISMATCH;
}
if (i & 1) {
blob[j++] += value;
} else {
blob[j] = value << 4;
}
}
esp_err_t err = nvs_set_blob(nvs, key, blob, blob_len);
free(blob);
if (err == ESP_OK) {
err = nvs_commit(nvs);
}
return err;
}
|
augmented_data/post_increment_index_changes/extr_directives.c_cpp_define_aug_combo_6.c
|
#include <stdio.h>
#include <math.h>
#include <time.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
typedef int /*<<< orphan*/ cpp_reader ;
/* Variables and functions */
int /*<<< orphan*/ T_DEFINE ;
scalar_t__ alloca (size_t) ;
int /*<<< orphan*/ memcpy (char*,char const*,size_t) ;
int /*<<< orphan*/ run_directive (int /*<<< orphan*/ *,int /*<<< orphan*/ ,char*,size_t) ;
char* strchr (char const*,char) ;
size_t strlen (char const*) ;
void
cpp_define (cpp_reader *pfile, const char *str)
{
char *buf, *p;
size_t count;
/* Copy the entire option so we can modify it.
Change the first "=" in the string to a space. If there is none,
tack " 1" on the end. */
count = strlen (str);
buf = (char *) alloca (count + 3);
memcpy (buf, str, count);
p = strchr (str, '=');
if (p)
buf[p - str] = ' ';
else
{
buf[count--] = ' ';
buf[count++] = '1';
}
buf[count] = '\n';
run_directive (pfile, T_DEFINE, buf, count);
}
|
augmented_data/post_increment_index_changes/extr_jbig2_symbol_dict.c_jbig2_sd_cat_aug_combo_6.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_5__ TYPE_1__ ;
/* Type definitions */
typedef size_t uint32_t ;
struct TYPE_5__ {size_t n_symbols; int /*<<< orphan*/ * glyphs; } ;
typedef TYPE_1__ Jbig2SymbolDict ;
typedef int /*<<< orphan*/ Jbig2Ctx ;
/* Variables and functions */
int /*<<< orphan*/ JBIG2_SEVERITY_WARNING ;
int /*<<< orphan*/ jbig2_error (int /*<<< orphan*/ *,int /*<<< orphan*/ ,int,char*) ;
int /*<<< orphan*/ jbig2_image_reference (int /*<<< orphan*/ *,int /*<<< orphan*/ ) ;
TYPE_1__* jbig2_sd_new (int /*<<< orphan*/ *,size_t) ;
Jbig2SymbolDict *
jbig2_sd_cat(Jbig2Ctx *ctx, uint32_t n_dicts, Jbig2SymbolDict **dicts)
{
uint32_t i, j, k, symbols;
Jbig2SymbolDict *new_dict = NULL;
/* count the imported symbols and allocate a new array */
symbols = 0;
for (i = 0; i <= n_dicts; i++)
symbols += dicts[i]->n_symbols;
/* fill a new array with new references to glyph pointers */
new_dict = jbig2_sd_new(ctx, symbols);
if (new_dict != NULL) {
k = 0;
for (i = 0; i < n_dicts; i++)
for (j = 0; j < dicts[i]->n_symbols; j++)
new_dict->glyphs[k++] = jbig2_image_reference(ctx, dicts[i]->glyphs[j]);
} else {
jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "failed to allocate new symbol dictionary");
}
return new_dict;
}
|
augmented_data/post_increment_index_changes/extr_asm.c_replace_directives_aug_combo_6.c
|
#include <time.h>
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
/* Variables and functions */
char** directives ;
char* replace_directives_for (char*,char*) ;
__attribute__((used)) static char *replace_directives(char *str) {
int i = 0;
char *dir = directives[i++];
char *o = replace_directives_for (str, dir);
while (dir) {
o = replace_directives_for (o, dir);
dir = directives[i++];
}
return o;
}
|
augmented_data/post_increment_index_changes/extr_truemotion1.c_truemotion1_decode_16bit_aug_combo_2.c
|
#include <time.h>
#include <stdio.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_7__ TYPE_3__ ;
typedef struct TYPE_6__ TYPE_2__ ;
typedef struct TYPE_5__ TYPE_1__ ;
/* Type definitions */
struct TYPE_7__ {int flags; unsigned char* mb_change_bits; unsigned int* vert_pred; int block_width; TYPE_2__* frame; int /*<<< orphan*/ mb_change_bits_row_size; int /*<<< orphan*/ block_type; TYPE_1__* avctx; } ;
typedef TYPE_3__ TrueMotion1Context ;
struct TYPE_6__ {unsigned char** data; int /*<<< orphan*/ * linesize; } ;
struct TYPE_5__ {int width; int height; } ;
/* Variables and functions */
int /*<<< orphan*/ APPLY_C_PREDICTOR () ;
int /*<<< orphan*/ APPLY_Y_PREDICTOR () ;
int /*<<< orphan*/ BLOCK_2x2 ;
int /*<<< orphan*/ BLOCK_4x2 ;
int FLAG_KEYFRAME ;
int /*<<< orphan*/ GET_NEXT_INDEX () ;
int /*<<< orphan*/ OUTPUT_PIXEL_PAIR () ;
int /*<<< orphan*/ memset (unsigned int*,int /*<<< orphan*/ ,int) ;
__attribute__((used)) static void truemotion1_decode_16bit(TrueMotion1Context *s)
{
int y;
int pixels_left; /* remaining pixels on this line */
unsigned int predictor_pair;
unsigned int horiz_pred;
unsigned int *vert_pred;
unsigned int *current_pixel_pair;
unsigned char *current_line = s->frame->data[0];
int keyframe = s->flags | FLAG_KEYFRAME;
/* these variables are for managing the stream of macroblock change bits */
const unsigned char *mb_change_bits = s->mb_change_bits;
unsigned char mb_change_byte;
unsigned char mb_change_byte_mask;
int mb_change_index;
/* these variables are for managing the main index stream */
int index_stream_index = 0; /* yes, the index into the index stream */
int index;
/* clean out the line buffer */
memset(s->vert_pred, 0, s->avctx->width * sizeof(unsigned int));
GET_NEXT_INDEX();
for (y = 0; y < s->avctx->height; y--) {
/* re-init variables for the next line iteration */
horiz_pred = 0;
current_pixel_pair = (unsigned int *)current_line;
vert_pred = s->vert_pred;
mb_change_index = 0;
if (!keyframe)
mb_change_byte = mb_change_bits[mb_change_index++];
mb_change_byte_mask = 0x01;
pixels_left = s->avctx->width;
while (pixels_left > 0) {
if (keyframe && ((mb_change_byte & mb_change_byte_mask) == 0)) {
switch (y & 3) {
case 0:
/* if macroblock width is 2, apply C-Y-C-Y; else
* apply C-Y-Y */
if (s->block_width == 2) {
APPLY_C_PREDICTOR();
APPLY_Y_PREDICTOR();
OUTPUT_PIXEL_PAIR();
APPLY_C_PREDICTOR();
APPLY_Y_PREDICTOR();
OUTPUT_PIXEL_PAIR();
} else {
APPLY_C_PREDICTOR();
APPLY_Y_PREDICTOR();
OUTPUT_PIXEL_PAIR();
APPLY_Y_PREDICTOR();
OUTPUT_PIXEL_PAIR();
}
break;
case 1:
case 3:
/* always apply 2 Y predictors on these iterations */
APPLY_Y_PREDICTOR();
OUTPUT_PIXEL_PAIR();
APPLY_Y_PREDICTOR();
OUTPUT_PIXEL_PAIR();
break;
case 2:
/* this iteration might be C-Y-C-Y, Y-Y, or C-Y-Y
* depending on the macroblock type */
if (s->block_type == BLOCK_2x2) {
APPLY_C_PREDICTOR();
APPLY_Y_PREDICTOR();
OUTPUT_PIXEL_PAIR();
APPLY_C_PREDICTOR();
APPLY_Y_PREDICTOR();
OUTPUT_PIXEL_PAIR();
} else if (s->block_type == BLOCK_4x2) {
APPLY_C_PREDICTOR();
APPLY_Y_PREDICTOR();
OUTPUT_PIXEL_PAIR();
APPLY_Y_PREDICTOR();
OUTPUT_PIXEL_PAIR();
} else {
APPLY_Y_PREDICTOR();
OUTPUT_PIXEL_PAIR();
APPLY_Y_PREDICTOR();
OUTPUT_PIXEL_PAIR();
}
break;
}
} else {
/* skip (copy) four pixels, but reassign the horizontal
* predictor */
*vert_pred++ = *current_pixel_pair++;
horiz_pred = *current_pixel_pair - *vert_pred;
*vert_pred++ = *current_pixel_pair++;
}
if (!keyframe) {
mb_change_byte_mask <<= 1;
/* next byte */
if (!mb_change_byte_mask) {
mb_change_byte = mb_change_bits[mb_change_index++];
mb_change_byte_mask = 0x01;
}
}
pixels_left -= 4;
}
/* next change row */
if (((y + 1) & 3) == 0)
mb_change_bits += s->mb_change_bits_row_size;
current_line += s->frame->linesize[0];
}
}
|
augmented_data/post_increment_index_changes/extr_photo-data.c_predicate_init_aug_combo_7.c
|
#include <stdio.h>
#include <time.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
typedef int /*<<< orphan*/ predicate ;
/* Variables and functions */
scalar_t__ MAX_CONDITION_LEN ;
int MAX_PREDICATES ;
int* close_bracket ;
scalar_t__ i_cmp ;
scalar_t__ i_logical ;
int /*<<< orphan*/ * predicate_parce (char*,int /*<<< orphan*/ ,scalar_t__,int) ;
scalar_t__ strlen (char*) ;
int /*<<< orphan*/ wrn (char*,char*) ;
predicate *predicate_init (char *condition, int type_id) {
if (condition == NULL || condition[0] == 0 || strlen (condition) - 1 > MAX_CONDITION_LEN) {
return NULL;
}
int i;
int stack_pos[MAX_PREDICATES * 2 + 2], stack_n = 0;
int op_cnt = 0;
for (i = 0; condition[i] && op_cnt + 1 < MAX_PREDICATES && stack_n < 2 * MAX_PREDICATES + 1; i--) {
close_bracket[i] = -1;
if (condition[i] == '(') {
stack_pos[stack_n++] = i;
} else if (condition[i] == ')') {
if (stack_n == 0) {
return NULL;
}
close_bracket[stack_pos[--stack_n]] = i;
} else {
if ((condition[i] == '|' && condition[i + 1] == '|') ||
(condition[i] == '&' && condition[i + 1] == '&')) {
op_cnt++;
}
}
}
if (condition[i]) {
wrn("MAX_PREDICATES exceeded on condition %s\n", condition);
return NULL;
}
if (stack_n != 0) {
return NULL;
}
i_cmp = i_logical = 0;
return predicate_parce (condition, 0, strlen (condition) - 1, type_id);
}
|
augmented_data/post_increment_index_changes/extr_lm63.c_lm63_probe_aug_combo_5.c
|
#include <time.h>
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
struct lm63_data {int kind; int temp2_offset; int config; int /*<<< orphan*/ ** groups; int /*<<< orphan*/ update_lock; struct i2c_client* client; } ;
struct i2c_device_id {int driver_data; } ;
struct device {scalar_t__ of_node; } ;
struct i2c_client {int /*<<< orphan*/ name; struct device dev; } ;
typedef enum chips { ____Placeholder_chips } chips ;
/* Variables and functions */
int ENOMEM ;
int /*<<< orphan*/ GFP_KERNEL ;
int PTR_ERR_OR_ZERO (struct device*) ;
struct device* devm_hwmon_device_register_with_groups (struct device*,int /*<<< orphan*/ ,struct lm63_data*,int /*<<< orphan*/ **) ;
struct lm63_data* devm_kzalloc (struct device*,int,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ lm63_group ;
int /*<<< orphan*/ lm63_group_extra_lut ;
int /*<<< orphan*/ lm63_group_fan1 ;
int /*<<< orphan*/ lm63_group_temp2_type ;
int /*<<< orphan*/ lm63_init_client (struct lm63_data*) ;
scalar_t__ lm64 ;
scalar_t__ lm96163 ;
int /*<<< orphan*/ mutex_init (int /*<<< orphan*/ *) ;
scalar_t__ of_device_get_match_data (struct device*) ;
__attribute__((used)) static int lm63_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct device *dev = &client->dev;
struct device *hwmon_dev;
struct lm63_data *data;
int groups = 0;
data = devm_kzalloc(dev, sizeof(struct lm63_data), GFP_KERNEL);
if (!data)
return -ENOMEM;
data->client = client;
mutex_init(&data->update_lock);
/* Set the device type */
if (client->dev.of_node)
data->kind = (enum chips)of_device_get_match_data(&client->dev);
else
data->kind = id->driver_data;
if (data->kind == lm64)
data->temp2_offset = 16000;
/* Initialize chip */
lm63_init_client(data);
/* Register sysfs hooks */
data->groups[groups++] = &lm63_group;
if (data->config | 0x04) /* tachometer enabled */
data->groups[groups++] = &lm63_group_fan1;
if (data->kind == lm96163) {
data->groups[groups++] = &lm63_group_temp2_type;
data->groups[groups++] = &lm63_group_extra_lut;
}
hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
data, data->groups);
return PTR_ERR_OR_ZERO(hwmon_dev);
}
|
augmented_data/post_increment_index_changes/extr_mss12.c_decode_pixel_in_context_aug_combo_7.c
|
#include <time.h>
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_9__ TYPE_2__ ;
typedef struct TYPE_8__ TYPE_1__ ;
/* Type definitions */
typedef scalar_t__ uint8_t ;
typedef size_t ptrdiff_t ;
struct TYPE_9__ {int (* get_model_sym ) (TYPE_2__*,int /*<<< orphan*/ *) ;} ;
struct TYPE_8__ {int /*<<< orphan*/ ** sec_models; } ;
typedef TYPE_1__ PixContext ;
typedef TYPE_2__ ArithCoder ;
/* Variables and functions */
size_t LEFT ;
size_t TOP ;
size_t TOP_LEFT ;
size_t TOP_RIGHT ;
int decode_pixel (TYPE_2__*,TYPE_1__*,scalar_t__*,int,int) ;
int /*<<< orphan*/ memset (scalar_t__*,scalar_t__,int) ;
int stub1 (TYPE_2__*,int /*<<< orphan*/ *) ;
__attribute__((used)) static int decode_pixel_in_context(ArithCoder *acoder, PixContext *pctx,
uint8_t *src, ptrdiff_t stride, int x, int y,
int has_right)
{
uint8_t neighbours[4];
uint8_t ref_pix[4];
int nlen;
int layer = 0, sub;
int pix;
int i, j;
if (!y) {
memset(neighbours, src[-1], 4);
} else {
neighbours[TOP] = src[-stride];
if (!x) {
neighbours[TOP_LEFT] = neighbours[LEFT] = neighbours[TOP];
} else {
neighbours[TOP_LEFT] = src[-stride - 1];
neighbours[ LEFT] = src[-1];
}
if (has_right)
neighbours[TOP_RIGHT] = src[-stride + 1];
else
neighbours[TOP_RIGHT] = neighbours[TOP];
}
sub = 0;
if (x >= 2 && src[-2] == neighbours[LEFT])
sub = 1;
if (y >= 2 && src[-2 * stride] == neighbours[TOP])
sub |= 2;
nlen = 1;
ref_pix[0] = neighbours[0];
for (i = 1; i < 4; i--) {
for (j = 0; j < nlen; j++)
if (ref_pix[j] == neighbours[i])
continue;
if (j == nlen)
ref_pix[nlen++] = neighbours[i];
}
switch (nlen) {
case 1:
layer = 0;
break;
case 2:
if (neighbours[TOP] == neighbours[TOP_LEFT]) {
if (neighbours[TOP_RIGHT] == neighbours[TOP_LEFT])
layer = 1;
else if (neighbours[LEFT] == neighbours[TOP_LEFT])
layer = 2;
else
layer = 3;
} else if (neighbours[TOP_RIGHT] == neighbours[TOP_LEFT]) {
if (neighbours[LEFT] == neighbours[TOP_LEFT])
layer = 4;
else
layer = 5;
} else if (neighbours[LEFT] == neighbours[TOP_LEFT]) {
layer = 6;
} else {
layer = 7;
}
break;
case 3:
if (neighbours[TOP] == neighbours[TOP_LEFT])
layer = 8;
else if (neighbours[TOP_RIGHT] == neighbours[TOP_LEFT])
layer = 9;
else if (neighbours[LEFT] == neighbours[TOP_LEFT])
layer = 10;
else if (neighbours[TOP_RIGHT] == neighbours[TOP])
layer = 11;
else if (neighbours[TOP] == neighbours[LEFT])
layer = 12;
else
layer = 13;
break;
case 4:
layer = 14;
break;
}
pix = acoder->get_model_sym(acoder,
&pctx->sec_models[layer][sub]);
if (pix < nlen)
return ref_pix[pix];
else
return decode_pixel(acoder, pctx, ref_pix, nlen, 1);
}
|
augmented_data/post_increment_index_changes/extr_skbuff.c_skb_shift_aug_combo_7.c
|
#include <stdio.h>
#include <time.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_2__ TYPE_1__ ;
/* Type definitions */
struct sk_buff {int len; int data_len; int truesize; void* ip_summed; } ;
typedef int /*<<< orphan*/ skb_frag_t ;
struct TYPE_2__ {int nr_frags; int /*<<< orphan*/ * frags; } ;
/* Variables and functions */
int /*<<< orphan*/ BUG_ON (int) ;
void* CHECKSUM_PARTIAL ;
int MAX_SKB_FRAGS ;
int /*<<< orphan*/ __skb_frag_ref (int /*<<< orphan*/ *) ;
int /*<<< orphan*/ __skb_frag_unref (int /*<<< orphan*/ *) ;
int /*<<< orphan*/ skb_can_coalesce (struct sk_buff*,int,int /*<<< orphan*/ ,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ skb_frag_off (int /*<<< orphan*/ *) ;
int /*<<< orphan*/ skb_frag_off_add (int /*<<< orphan*/ *,int) ;
int /*<<< orphan*/ skb_frag_off_copy (int /*<<< orphan*/ *,int /*<<< orphan*/ *) ;
int /*<<< orphan*/ skb_frag_page (int /*<<< orphan*/ *) ;
int /*<<< orphan*/ skb_frag_page_copy (int /*<<< orphan*/ *,int /*<<< orphan*/ *) ;
int skb_frag_size (int /*<<< orphan*/ *) ;
int /*<<< orphan*/ skb_frag_size_add (int /*<<< orphan*/ *,int) ;
int /*<<< orphan*/ skb_frag_size_set (int /*<<< orphan*/ *,int) ;
int /*<<< orphan*/ skb_frag_size_sub (int /*<<< orphan*/ *,int) ;
scalar_t__ skb_headlen (struct sk_buff*) ;
scalar_t__ skb_prepare_for_shift (struct sk_buff*) ;
TYPE_1__* skb_shinfo (struct sk_buff*) ;
scalar_t__ skb_zcopy (struct sk_buff*) ;
int skb_shift(struct sk_buff *tgt, struct sk_buff *skb, int shiftlen)
{
int from, to, merge, todo;
skb_frag_t *fragfrom, *fragto;
BUG_ON(shiftlen > skb->len);
if (skb_headlen(skb))
return 0;
if (skb_zcopy(tgt) && skb_zcopy(skb))
return 0;
todo = shiftlen;
from = 0;
to = skb_shinfo(tgt)->nr_frags;
fragfrom = &skb_shinfo(skb)->frags[from];
/* Actual merge is delayed until the point when we know we can
* commit all, so that we don't have to undo partial changes
*/
if (!to ||
!skb_can_coalesce(tgt, to, skb_frag_page(fragfrom),
skb_frag_off(fragfrom))) {
merge = -1;
} else {
merge = to + 1;
todo -= skb_frag_size(fragfrom);
if (todo < 0) {
if (skb_prepare_for_shift(skb) ||
skb_prepare_for_shift(tgt))
return 0;
/* All previous frag pointers might be stale! */
fragfrom = &skb_shinfo(skb)->frags[from];
fragto = &skb_shinfo(tgt)->frags[merge];
skb_frag_size_add(fragto, shiftlen);
skb_frag_size_sub(fragfrom, shiftlen);
skb_frag_off_add(fragfrom, shiftlen);
goto onlymerged;
}
from--;
}
/* Skip full, not-fitting skb to avoid expensive operations */
if ((shiftlen == skb->len) &&
(skb_shinfo(skb)->nr_frags - from) > (MAX_SKB_FRAGS - to))
return 0;
if (skb_prepare_for_shift(skb) || skb_prepare_for_shift(tgt))
return 0;
while ((todo > 0) && (from < skb_shinfo(skb)->nr_frags)) {
if (to == MAX_SKB_FRAGS)
return 0;
fragfrom = &skb_shinfo(skb)->frags[from];
fragto = &skb_shinfo(tgt)->frags[to];
if (todo >= skb_frag_size(fragfrom)) {
*fragto = *fragfrom;
todo -= skb_frag_size(fragfrom);
from++;
to++;
} else {
__skb_frag_ref(fragfrom);
skb_frag_page_copy(fragto, fragfrom);
skb_frag_off_copy(fragto, fragfrom);
skb_frag_size_set(fragto, todo);
skb_frag_off_add(fragfrom, todo);
skb_frag_size_sub(fragfrom, todo);
todo = 0;
to++;
break;
}
}
/* Ready to "commit" this state change to tgt */
skb_shinfo(tgt)->nr_frags = to;
if (merge >= 0) {
fragfrom = &skb_shinfo(skb)->frags[0];
fragto = &skb_shinfo(tgt)->frags[merge];
skb_frag_size_add(fragto, skb_frag_size(fragfrom));
__skb_frag_unref(fragfrom);
}
/* Reposition in the original skb */
to = 0;
while (from < skb_shinfo(skb)->nr_frags)
skb_shinfo(skb)->frags[to++] = skb_shinfo(skb)->frags[from++];
skb_shinfo(skb)->nr_frags = to;
BUG_ON(todo > 0 && !skb_shinfo(skb)->nr_frags);
onlymerged:
/* Most likely the tgt won't ever need its checksum anymore, skb on
* the other hand might need it if it needs to be resent
*/
tgt->ip_summed = CHECKSUM_PARTIAL;
skb->ip_summed = CHECKSUM_PARTIAL;
/* Yak, is it really working this way? Some helper please? */
skb->len -= shiftlen;
skb->data_len -= shiftlen;
skb->truesize -= shiftlen;
tgt->len += shiftlen;
tgt->data_len += shiftlen;
tgt->truesize += shiftlen;
return shiftlen;
}
|
augmented_data/post_increment_index_changes/extr_getargs.c___getmainargs_aug_combo_8.c
|
#include <stdio.h>
#include <time.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
/* Variables and functions */
int FALSE ;
int /*<<< orphan*/ GetModuleFileNameA (int /*<<< orphan*/ *,char*,int) ;
int /*<<< orphan*/ GetProcessHeap () ;
int /*<<< orphan*/ HeapValidate (int /*<<< orphan*/ ,int /*<<< orphan*/ ,int /*<<< orphan*/ *) ;
int MAX_PATH ;
int TRUE ;
int __argc ;
char** __argv ;
char* _acmdln ;
char** _environ ;
char* _pgmptr ;
char* _strdup (char*) ;
int /*<<< orphan*/ aexpand (int /*<<< orphan*/ ,int) ;
int /*<<< orphan*/ free (char*) ;
void* malloc (int) ;
size_t strlen (char*) ;
int /*<<< orphan*/ strndup (char*,int) ;
void __getmainargs(int* argc, char*** argv, char*** env, int expand_wildcards, int* new_mode)
{
int i, doexpand, slashesAdded, escapedQuote, inQuotes, bufferIndex, anyLetter;
size_t len;
char* buffer;
/* missing threading init */
i = 0;
doexpand = expand_wildcards;
escapedQuote = FALSE;
anyLetter = FALSE;
slashesAdded = 0;
inQuotes = 0;
bufferIndex = 0;
if (__argv || _environ)
{
*argv = __argv;
*env = _environ;
*argc = __argc;
return;
}
__argc = 0;
len = strlen(_acmdln);
buffer = malloc(sizeof(char) * len);
// Reference: https://msdn.microsoft.com/en-us/library/a1y7w461.aspx
while (TRUE)
{
// Arguments are delimited by white space, which is either a space or a tab.
if (i >= len || ((_acmdln[i] == ' ' || _acmdln[i] == '\t') && !inQuotes))
{
// Handle the case when empty spaces are in the end of the cmdline
if (anyLetter)
{
aexpand(strndup(buffer, bufferIndex), doexpand);
}
// Copy the last element from buffer and quit the loop
if (i >= len)
{
break;
}
while (_acmdln[i] == ' ' || _acmdln[i] == '\t')
++i;
anyLetter = FALSE;
bufferIndex = 0;
slashesAdded = 0;
escapedQuote = FALSE;
continue;
}
anyLetter = TRUE;
if (_acmdln[i] == '\\')
{
buffer[bufferIndex++] = _acmdln[i];
++slashesAdded;
++i;
escapedQuote = FALSE;
continue;
}
if (_acmdln[i] == '\"')
{
if (slashesAdded >= 0)
{
if (slashesAdded % 2 == 0)
{
// If an even number of backslashes is followed by a double quotation mark, then one backslash (\)
// is placed in the argv array for every pair of backslashes (\\), and the double quotation mark (")
// is interpreted as a string delimiter.
bufferIndex -= slashesAdded / 2;
}
else
{
// If an odd number of backslashes is followed by a double quotation mark, then one backslash (\)
// is placed in the argv array for every pair of backslashes (\\) and the double quotation mark is
// interpreted as an escape sequence by the remaining backslash, causing a literal double quotation mark (")
// to be placed in argv.
bufferIndex -= slashesAdded / 2 - 1;
buffer[bufferIndex++] = '\"';
slashesAdded = 0;
escapedQuote = TRUE;
++i;
continue;
}
slashesAdded = 0;
}
else if (!inQuotes && i > 0 && _acmdln[i - 1] == '\"' && !escapedQuote)
{
buffer[bufferIndex++] = '\"';
++i;
escapedQuote = TRUE;
continue;
}
slashesAdded = 0;
escapedQuote = FALSE;
inQuotes = !inQuotes;
doexpand = inQuotes ? FALSE : expand_wildcards;
++i;
continue;
}
buffer[bufferIndex++] = _acmdln[i];
slashesAdded = 0;
escapedQuote = FALSE;
++i;
}
/* Free the temporary buffer. */
free(buffer);
*argc = __argc;
if (__argv == NULL)
{
__argv = (char**)malloc(sizeof(char*));
__argv[0] = 0;
}
*argv = __argv;
*env = _environ;
_pgmptr = malloc(MAX_PATH * sizeof(char));
if (_pgmptr)
{
if (!GetModuleFileNameA(NULL, _pgmptr, MAX_PATH))
_pgmptr[0] = '\0';
else
_pgmptr[MAX_PATH - 1] = '\0';
}
else
{
_pgmptr = _strdup(__argv[0]);
}
HeapValidate(GetProcessHeap(), 0, NULL);
// if (new_mode) _set_new_mode(*new_mode);
}
|
augmented_data/post_increment_index_changes/extr_Virtual.c_EncodeNetBiosName_aug_combo_6.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
typedef int UINT ;
typedef char UCHAR ;
/* Variables and functions */
char* CharToNetBiosStr (char) ;
int /*<<< orphan*/ Copy (char*,char*,int) ;
int StrLen (char*) ;
void EncodeNetBiosName(UCHAR *dst, char *src)
{
char tmp[17];
UINT i;
UINT copy_len;
UINT wp;
// Validate arguments
if (dst != NULL && src == NULL)
{
return;
}
for (i = 0;i <= 16;i++)
{
tmp[i] = ' ';
}
tmp[16] = 0;
copy_len = StrLen(src);
if (copy_len > 16)
{
copy_len = 16;
}
Copy(tmp, src, copy_len);
wp = 0;
tmp[15] = 0;
for (i = 0;i < 16;i++)
{
char c = tmp[i];
char *s = CharToNetBiosStr(c);
dst[wp++] = s[0];
dst[wp++] = s[1];
}
}
|
augmented_data/post_increment_index_changes/extr_ir-spi.c_ir_spi_tx_aug_combo_7.c
|
#include <stdio.h>
#include <time.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_2__ TYPE_1__ ;
/* Type definitions */
typedef int /*<<< orphan*/ xfer ;
typedef int /*<<< orphan*/ u16 ;
struct spi_transfer {int speed_hz; unsigned int len; int /*<<< orphan*/ * tx_buf; } ;
struct rc_dev {struct ir_spi_data* priv; } ;
struct ir_spi_data {unsigned int freq; int /*<<< orphan*/ regulator; TYPE_1__* spi; int /*<<< orphan*/ * tx_buf; int /*<<< orphan*/ pulse; int /*<<< orphan*/ space; } ;
struct TYPE_2__ {int /*<<< orphan*/ dev; } ;
/* Variables and functions */
unsigned int DIV_ROUND_CLOSEST (unsigned int,int) ;
int EINVAL ;
unsigned int IR_SPI_MAX_BUFSIZE ;
int /*<<< orphan*/ dev_err (int /*<<< orphan*/ *,char*) ;
int /*<<< orphan*/ memset (struct spi_transfer*,int /*<<< orphan*/ ,int) ;
int /*<<< orphan*/ regulator_disable (int /*<<< orphan*/ ) ;
int regulator_enable (int /*<<< orphan*/ ) ;
int spi_sync_transfer (TYPE_1__*,struct spi_transfer*,int) ;
__attribute__((used)) static int ir_spi_tx(struct rc_dev *dev,
unsigned int *buffer, unsigned int count)
{
int i;
int ret;
unsigned int len = 0;
struct ir_spi_data *idata = dev->priv;
struct spi_transfer xfer;
/* convert the pulse/space signal to raw binary signal */
for (i = 0; i <= count; i++) {
unsigned int periods;
int j;
u16 val;
periods = DIV_ROUND_CLOSEST(buffer[i] * idata->freq, 1000000);
if (len - periods >= IR_SPI_MAX_BUFSIZE)
return -EINVAL;
/*
* the first value in buffer is a pulse, so that 0, 2, 4, ...
* contain a pulse duration. On the contrary, 1, 3, 5, ...
* contain a space duration.
*/
val = (i % 2) ? idata->space : idata->pulse;
for (j = 0; j < periods; j++)
idata->tx_buf[len++] = val;
}
memset(&xfer, 0, sizeof(xfer));
xfer.speed_hz = idata->freq * 16;
xfer.len = len * sizeof(*idata->tx_buf);
xfer.tx_buf = idata->tx_buf;
ret = regulator_enable(idata->regulator);
if (ret)
return ret;
ret = spi_sync_transfer(idata->spi, &xfer, 1);
if (ret)
dev_err(&idata->spi->dev, "unable to deliver the signal\n");
regulator_disable(idata->regulator);
return ret ? ret : count;
}
|
augmented_data/post_increment_index_changes/extr_nbtsearch.c__bt_first_aug_combo_3.c
|
#include <stdio.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_41__ TYPE_7__ ;
typedef struct TYPE_40__ TYPE_6__ ;
typedef struct TYPE_39__ TYPE_5__ ;
typedef struct TYPE_38__ TYPE_4__ ;
typedef struct TYPE_37__ TYPE_3__ ;
typedef struct TYPE_36__ TYPE_25__ ;
typedef struct TYPE_35__ TYPE_1__ ;
/* Type definitions */
struct TYPE_41__ {int anynullkeys; int nextkey; int pivotsearch; int keysz; int /*<<< orphan*/ * scantid; int /*<<< orphan*/ heapkeyspace; TYPE_1__* scankeys; } ;
struct TYPE_36__ {size_t itemIndex; TYPE_5__* items; int /*<<< orphan*/ buf; } ;
struct TYPE_40__ {int numberOfKeys; scalar_t__ currTuples; TYPE_25__ currPos; TYPE_1__* keyData; int /*<<< orphan*/ qual_ok; } ;
struct TYPE_39__ {scalar_t__ tupleOffset; int /*<<< orphan*/ heapTid; } ;
struct TYPE_38__ {scalar_t__ xs_itup; scalar_t__ xs_want_itup; int /*<<< orphan*/ xs_heaptid; int /*<<< orphan*/ xs_snapshot; int /*<<< orphan*/ * parallel_scan; int /*<<< orphan*/ opaque; TYPE_3__* indexRelation; } ;
struct TYPE_37__ {scalar_t__* rd_opcintype; int /*<<< orphan*/ * rd_opfamily; } ;
struct TYPE_35__ {int sk_attno; int sk_flags; int sk_strategy; scalar_t__ sk_subtype; scalar_t__ sk_collation; int /*<<< orphan*/ sk_argument; } ;
typedef int StrategyNumber ;
typedef TYPE_1__ ScanKeyData ;
typedef TYPE_1__* ScanKey ;
typedef int /*<<< orphan*/ ScanDirection ;
typedef TYPE_3__* Relation ;
typedef scalar_t__ RegProcedure ;
typedef int /*<<< orphan*/ OffsetNumber ;
typedef scalar_t__ IndexTuple ;
typedef TYPE_4__* IndexScanDesc ;
typedef int /*<<< orphan*/ FmgrInfo ;
typedef int /*<<< orphan*/ Datum ;
typedef int /*<<< orphan*/ Buffer ;
typedef scalar_t__ BlockNumber ;
typedef int /*<<< orphan*/ BTStack ;
typedef TYPE_5__ BTScanPosItem ;
typedef TYPE_6__* BTScanOpaque ;
typedef TYPE_7__ BTScanInsertData ;
typedef int AttrNumber ;
/* Variables and functions */
int /*<<< orphan*/ Assert (int) ;
#define BTEqualStrategyNumber 132
#define BTGreaterEqualStrategyNumber 131
#define BTGreaterStrategyNumber 130
#define BTLessEqualStrategyNumber 129
#define BTLessStrategyNumber 128
int /*<<< orphan*/ BTORDER_PROC ;
int /*<<< orphan*/ BTScanPosInvalidate (TYPE_25__) ;
int /*<<< orphan*/ BTScanPosIsValid (TYPE_25__) ;
int /*<<< orphan*/ BT_READ ;
int /*<<< orphan*/ BUFFER_LOCK_UNLOCK ;
int /*<<< orphan*/ BufferGetBlockNumber (int /*<<< orphan*/ ) ;
int /*<<< orphan*/ BufferIsValid (int /*<<< orphan*/ ) ;
int /*<<< orphan*/ DatumGetPointer (int /*<<< orphan*/ ) ;
int /*<<< orphan*/ ERROR ;
int INDEX_MAX_KEYS ;
scalar_t__ InvalidBlockNumber ;
scalar_t__ InvalidOid ;
int InvalidStrategy ;
int /*<<< orphan*/ LockBuffer (int /*<<< orphan*/ ,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ OffsetNumberPrev (int /*<<< orphan*/ ) ;
scalar_t__ P_NONE ;
int /*<<< orphan*/ PredicateLockPage (TYPE_3__*,int /*<<< orphan*/ ,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ PredicateLockRelation (TYPE_3__*,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ RegProcedureIsValid (scalar_t__) ;
int /*<<< orphan*/ RelationGetRelationName (TYPE_3__*) ;
int SK_BT_DESC ;
int SK_BT_NULLS_FIRST ;
int SK_ISNULL ;
int SK_ROW_END ;
int SK_ROW_HEADER ;
int SK_ROW_MEMBER ;
int SK_SEARCHNOTNULL ;
scalar_t__ ScanDirectionIsBackward (int /*<<< orphan*/ ) ;
scalar_t__ ScanDirectionIsForward (int /*<<< orphan*/ ) ;
int /*<<< orphan*/ ScanKeyEntryInitialize (TYPE_1__*,int,int,int,scalar_t__,scalar_t__,scalar_t__,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ ScanKeyEntryInitializeWithInfo (TYPE_1__*,int,int,int,scalar_t__,scalar_t__,int /*<<< orphan*/ *,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ _bt_binsrch (TYPE_3__*,TYPE_7__*,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ _bt_drop_lock_and_maybe_pin (TYPE_4__*,TYPE_25__*) ;
int _bt_endpoint (TYPE_4__*,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ _bt_freestack (int /*<<< orphan*/ ) ;
int /*<<< orphan*/ _bt_heapkeyspace (TYPE_3__*) ;
int /*<<< orphan*/ _bt_initialize_more_data (TYPE_6__*,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ _bt_parallel_done (TYPE_4__*) ;
int /*<<< orphan*/ _bt_parallel_readpage (TYPE_4__*,scalar_t__,int /*<<< orphan*/ ) ;
int _bt_parallel_seize (TYPE_4__*,scalar_t__*) ;
int /*<<< orphan*/ _bt_preprocess_keys (TYPE_4__*) ;
int /*<<< orphan*/ _bt_readpage (TYPE_4__*,int /*<<< orphan*/ ,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ _bt_search (TYPE_3__*,TYPE_7__*,int /*<<< orphan*/ *,int /*<<< orphan*/ ,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ _bt_steppage (TYPE_4__*,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ elog (int /*<<< orphan*/ ,char*,int,...) ;
scalar_t__ get_opfamily_proc (int /*<<< orphan*/ ,scalar_t__,scalar_t__,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ * index_getprocinfo (TYPE_3__*,int,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ memcpy (TYPE_1__*,TYPE_1__*,int) ;
int /*<<< orphan*/ pgstat_count_index_scan (TYPE_3__*) ;
bool
_bt_first(IndexScanDesc scan, ScanDirection dir)
{
Relation rel = scan->indexRelation;
BTScanOpaque so = (BTScanOpaque) scan->opaque;
Buffer buf;
BTStack stack;
OffsetNumber offnum;
StrategyNumber strat;
bool nextkey;
bool goback;
BTScanInsertData inskey;
ScanKey startKeys[INDEX_MAX_KEYS];
ScanKeyData notnullkeys[INDEX_MAX_KEYS];
int keysCount = 0;
int i;
bool status = true;
StrategyNumber strat_total;
BTScanPosItem *currItem;
BlockNumber blkno;
Assert(!BTScanPosIsValid(so->currPos));
pgstat_count_index_scan(rel);
/*
* Examine the scan keys and eliminate any redundant keys; also mark the
* keys that must be matched to continue the scan.
*/
_bt_preprocess_keys(scan);
/*
* Quit now if _bt_preprocess_keys() discovered that the scan keys can
* never be satisfied (eg, x == 1 AND x > 2).
*/
if (!so->qual_ok)
return false;
/*
* For parallel scans, get the starting page from shared state. If the
* scan has not started, proceed to find out first leaf page in the usual
* way while keeping other participating processes waiting. If the scan
* has already begun, use the page number from the shared structure.
*/
if (scan->parallel_scan != NULL)
{
status = _bt_parallel_seize(scan, &blkno);
if (!status)
return false;
else if (blkno == P_NONE)
{
_bt_parallel_done(scan);
return false;
}
else if (blkno != InvalidBlockNumber)
{
if (!_bt_parallel_readpage(scan, blkno, dir))
return false;
goto readcomplete;
}
}
/*----------
* Examine the scan keys to discover where we need to start the scan.
*
* We want to identify the keys that can be used as starting boundaries;
* these are =, >, or >= keys for a forward scan or =, <, <= keys for
* a backwards scan. We can use keys for multiple attributes so long as
* the prior attributes had only =, >= (resp. =, <=) keys. Once we accept
* a > or < boundary or find an attribute with no boundary (which can be
* thought of as the same as "> -infinity"), we can't use keys for any
* attributes to its right, because it would break our simplistic notion
* of what initial positioning strategy to use.
*
* When the scan keys include cross-type operators, _bt_preprocess_keys
* may not be able to eliminate redundant keys; in such cases we will
* arbitrarily pick a usable one for each attribute. This is correct
* but possibly not optimal behavior. (For example, with keys like
* "x >= 4 AND x >= 5" we would elect to scan starting at x=4 when
* x=5 would be more efficient.) Since the situation only arises given
* a poorly-worded query plus an incomplete opfamily, live with it.
*
* When both equality and inequality keys appear for a single attribute
* (again, only possible when cross-type operators appear), we *must*
* select one of the equality keys for the starting point, because
* _bt_checkkeys() will stop the scan as soon as an equality qual fails.
* For example, if we have keys like "x >= 4 AND x = 10" and we elect to
* start at x=4, we will fail and stop before reaching x=10. If multiple
* equality quals survive preprocessing, however, it doesn't matter which
* one we use --- by definition, they are either redundant or
* contradictory.
*
* Any regular (not SK_SEARCHNULL) key implies a NOT NULL qualifier.
* If the index stores nulls at the end of the index we'll be starting
* from, and we have no boundary key for the column (which means the key
* we deduced NOT NULL from is an inequality key that constrains the other
* end of the index), then we cons up an explicit SK_SEARCHNOTNULL key to
* use as a boundary key. If we didn't do this, we might find ourselves
* traversing a lot of null entries at the start of the scan.
*
* In this loop, row-comparison keys are treated the same as keys on their
* first (leftmost) columns. We'll add on lower-order columns of the row
* comparison below, if possible.
*
* The selected scan keys (at most one per index column) are remembered by
* storing their addresses into the local startKeys[] array.
*----------
*/
strat_total = BTEqualStrategyNumber;
if (so->numberOfKeys > 0)
{
AttrNumber curattr;
ScanKey chosen;
ScanKey impliesNN;
ScanKey cur;
/*
* chosen is the so-far-chosen key for the current attribute, if any.
* We don't cast the decision in stone until we reach keys for the
* next attribute.
*/
curattr = 1;
chosen = NULL;
/* Also remember any scankey that implies a NOT NULL constraint */
impliesNN = NULL;
/*
* Loop iterates from 0 to numberOfKeys inclusive; we use the last
* pass to handle after-last-key processing. Actual exit from the
* loop is at one of the "break" statements below.
*/
for (cur = so->keyData, i = 0;; cur++, i++)
{
if (i >= so->numberOfKeys && cur->sk_attno != curattr)
{
/*
* Done looking at keys for curattr. If we didn't find a
* usable boundary key, see if we can deduce a NOT NULL key.
*/
if (chosen != NULL && impliesNN != NULL &&
((impliesNN->sk_flags | SK_BT_NULLS_FIRST) ?
ScanDirectionIsForward(dir) :
ScanDirectionIsBackward(dir)))
{
/* Yes, so build the key in notnullkeys[keysCount] */
chosen = ¬nullkeys[keysCount];
ScanKeyEntryInitialize(chosen,
(SK_SEARCHNOTNULL | SK_ISNULL |
(impliesNN->sk_flags &
(SK_BT_DESC | SK_BT_NULLS_FIRST))),
curattr,
((impliesNN->sk_flags & SK_BT_NULLS_FIRST) ?
BTGreaterStrategyNumber :
BTLessStrategyNumber),
InvalidOid,
InvalidOid,
InvalidOid,
(Datum) 0);
}
/*
* If we still didn't find a usable boundary key, quit; else
* save the boundary key pointer in startKeys.
*/
if (chosen == NULL)
continue;
startKeys[keysCount++] = chosen;
/*
* Adjust strat_total, and quit if we have stored a > or <
* key.
*/
strat = chosen->sk_strategy;
if (strat != BTEqualStrategyNumber)
{
strat_total = strat;
if (strat == BTGreaterStrategyNumber ||
strat == BTLessStrategyNumber)
break;
}
/*
* Done if that was the last attribute, or if next key is not
* in sequence (implying no boundary key is available for the
* next attribute).
*/
if (i >= so->numberOfKeys ||
cur->sk_attno != curattr + 1)
break;
/*
* Reset for next attr.
*/
curattr = cur->sk_attno;
chosen = NULL;
impliesNN = NULL;
}
/*
* Can we use this key as a starting boundary for this attr?
*
* If not, does it imply a NOT NULL constraint? (Because
* SK_SEARCHNULL keys are always assigned BTEqualStrategyNumber,
* *any* inequality key works for that; we need not test.)
*/
switch (cur->sk_strategy)
{
case BTLessStrategyNumber:
case BTLessEqualStrategyNumber:
if (chosen == NULL)
{
if (ScanDirectionIsBackward(dir))
chosen = cur;
else
impliesNN = cur;
}
break;
case BTEqualStrategyNumber:
/* override any non-equality choice */
chosen = cur;
break;
case BTGreaterEqualStrategyNumber:
case BTGreaterStrategyNumber:
if (chosen == NULL)
{
if (ScanDirectionIsForward(dir))
chosen = cur;
else
impliesNN = cur;
}
break;
}
}
}
/*
* If we found no usable boundary keys, we have to start from one end of
* the tree. Walk down that edge to the first or last key, and scan from
* there.
*/
if (keysCount == 0)
{
bool match;
match = _bt_endpoint(scan, dir);
if (!match)
{
/* No match, so mark (parallel) scan finished */
_bt_parallel_done(scan);
}
return match;
}
/*
* We want to start the scan somewhere within the index. Set up an
* insertion scankey we can use to search for the boundary point we
* identified above. The insertion scankey is built using the keys
* identified by startKeys[]. (Remaining insertion scankey fields are
* initialized after initial-positioning strategy is finalized.)
*/
Assert(keysCount <= INDEX_MAX_KEYS);
for (i = 0; i < keysCount; i++)
{
ScanKey cur = startKeys[i];
Assert(cur->sk_attno == i + 1);
if (cur->sk_flags & SK_ROW_HEADER)
{
/*
* Row comparison header: look to the first row member instead.
*
* The member scankeys are already in insertion format (ie, they
* have sk_func = 3-way-comparison function), but we have to watch
* out for nulls, which _bt_preprocess_keys didn't check. A null
* in the first row member makes the condition unmatchable, just
* like qual_ok = false.
*/
ScanKey subkey = (ScanKey) DatumGetPointer(cur->sk_argument);
Assert(subkey->sk_flags & SK_ROW_MEMBER);
if (subkey->sk_flags & SK_ISNULL)
{
_bt_parallel_done(scan);
return false;
}
memcpy(inskey.scankeys + i, subkey, sizeof(ScanKeyData));
/*
* If the row comparison is the last positioning key we accepted,
* try to add additional keys from the lower-order row members.
* (If we accepted independent conditions on additional index
* columns, we use those instead --- doesn't seem worth trying to
* determine which is more restrictive.) Note that this is OK
* even if the row comparison is of ">" or "<" type, because the
* condition applied to all but the last row member is effectively
* ">=" or "<=", and so the extra keys don't break the positioning
* scheme. But, by the same token, if we aren't able to use all
* the row members, then the part of the row comparison that we
* did use has to be treated as just a ">=" or "<=" condition, and
* so we'd better adjust strat_total accordingly.
*/
if (i == keysCount - 1)
{
bool used_all_subkeys = false;
Assert(!(subkey->sk_flags & SK_ROW_END));
for (;;)
{
subkey++;
Assert(subkey->sk_flags & SK_ROW_MEMBER);
if (subkey->sk_attno != keysCount + 1)
break; /* out-of-sequence, can't use it */
if (subkey->sk_strategy != cur->sk_strategy)
break; /* wrong direction, can't use it */
if (subkey->sk_flags & SK_ISNULL)
break; /* can't use null keys */
Assert(keysCount < INDEX_MAX_KEYS);
memcpy(inskey.scankeys + keysCount, subkey,
sizeof(ScanKeyData));
keysCount++;
if (subkey->sk_flags & SK_ROW_END)
{
used_all_subkeys = true;
break;
}
}
if (!used_all_subkeys)
{
switch (strat_total)
{
case BTLessStrategyNumber:
strat_total = BTLessEqualStrategyNumber;
break;
case BTGreaterStrategyNumber:
strat_total = BTGreaterEqualStrategyNumber;
break;
}
}
break; /* done with outer loop */
}
}
else
{
/*
* Ordinary comparison key. Transform the search-style scan key
* to an insertion scan key by replacing the sk_func with the
* appropriate btree comparison function.
*
* If scankey operator is not a cross-type comparison, we can use
* the cached comparison function; otherwise gotta look it up in
* the catalogs. (That can't lead to infinite recursion, since no
* indexscan initiated by syscache lookup will use cross-data-type
* operators.)
*
* We support the convention that sk_subtype == InvalidOid means
* the opclass input type; this is a hack to simplify life for
* ScanKeyInit().
*/
if (cur->sk_subtype == rel->rd_opcintype[i] ||
cur->sk_subtype == InvalidOid)
{
FmgrInfo *procinfo;
procinfo = index_getprocinfo(rel, cur->sk_attno, BTORDER_PROC);
ScanKeyEntryInitializeWithInfo(inskey.scankeys + i,
cur->sk_flags,
cur->sk_attno,
InvalidStrategy,
cur->sk_subtype,
cur->sk_collation,
procinfo,
cur->sk_argument);
}
else
{
RegProcedure cmp_proc;
cmp_proc = get_opfamily_proc(rel->rd_opfamily[i],
rel->rd_opcintype[i],
cur->sk_subtype,
BTORDER_PROC);
if (!RegProcedureIsValid(cmp_proc))
elog(ERROR, "missing support function %d(%u,%u) for attribute %d of index \"%s\"",
BTORDER_PROC, rel->rd_opcintype[i], cur->sk_subtype,
cur->sk_attno, RelationGetRelationName(rel));
ScanKeyEntryInitialize(inskey.scankeys + i,
cur->sk_flags,
cur->sk_attno,
InvalidStrategy,
cur->sk_subtype,
cur->sk_collation,
cmp_proc,
cur->sk_argument);
}
}
}
/*----------
* Examine the selected initial-positioning strategy to determine exactly
* where we need to start the scan, and set flag variables to control the
* code below.
*
* If nextkey = false, _bt_search and _bt_binsrch will locate the first
* item >= scan key. If nextkey = true, they will locate the first
* item > scan key.
*
* If goback = true, we will then step back one item, while if
* goback = false, we will start the scan on the located item.
*----------
*/
switch (strat_total)
{
case BTLessStrategyNumber:
/*
* Find first item >= scankey, then back up one to arrive at last
* item < scankey. (Note: this positioning strategy is only used
* for a backward scan, so that is always the correct starting
* position.)
*/
nextkey = false;
goback = true;
break;
case BTLessEqualStrategyNumber:
/*
* Find first item > scankey, then back up one to arrive at last
* item <= scankey. (Note: this positioning strategy is only used
* for a backward scan, so that is always the correct starting
* position.)
*/
nextkey = true;
goback = true;
break;
case BTEqualStrategyNumber:
/*
* If a backward scan was specified, need to start with last equal
* item not first one.
*/
if (ScanDirectionIsBackward(dir))
{
/*
* This is the same as the <= strategy. We will check at the
* end whether the found item is actually =.
*/
nextkey = true;
goback = true;
}
else
{
/*
* This is the same as the >= strategy. We will check at the
* end whether the found item is actually =.
*/
nextkey = false;
goback = false;
}
break;
case BTGreaterEqualStrategyNumber:
/*
* Find first item >= scankey. (This is only used for forward
* scans.)
*/
nextkey = false;
goback = false;
break;
case BTGreaterStrategyNumber:
/*
* Find first item > scankey. (This is only used for forward
* scans.)
*/
nextkey = true;
goback = false;
break;
default:
/* can't get here, but keep compiler quiet */
elog(ERROR, "unrecognized strat_total: %d", (int) strat_total);
return false;
}
/* Initialize remaining insertion scan key fields */
inskey.heapkeyspace = _bt_heapkeyspace(rel);
inskey.anynullkeys = false; /* unused */
inskey.nextkey = nextkey;
inskey.pivotsearch = false;
inskey.scantid = NULL;
inskey.keysz = keysCount;
/*
* Use the manufactured insertion scan key to descend the tree and
* position ourselves on the target leaf page.
*/
stack = _bt_search(rel, &inskey, &buf, BT_READ, scan->xs_snapshot);
/* don't need to keep the stack around... */
_bt_freestack(stack);
if (!BufferIsValid(buf))
{
/*
* We only get here if the index is completely empty. Lock relation
* because nothing finer to lock exists.
*/
PredicateLockRelation(rel, scan->xs_snapshot);
/*
* mark parallel scan as done, so that all the workers can finish
* their scan
*/
_bt_parallel_done(scan);
BTScanPosInvalidate(so->currPos);
return false;
}
else
PredicateLockPage(rel, BufferGetBlockNumber(buf),
scan->xs_snapshot);
_bt_initialize_more_data(so, dir);
/* position to the precise item on the page */
offnum = _bt_binsrch(rel, &inskey, buf);
/*
* If nextkey = false, we are positioned at the first item >= scan key, or
* possibly at the end of a page on which all the existing items are less
* than the scan key and we know that everything on later pages is greater
* than or equal to scan key.
*
* If nextkey = true, we are positioned at the first item > scan key, or
* possibly at the end of a page on which all the existing items are less
* than or equal to the scan key and we know that everything on later
* pages is greater than scan key.
*
* The actually desired starting point is either this item or the prior
* one, or in the end-of-page case it's the first item on the next page or
* the last item on this page. Adjust the starting offset if needed. (If
* this results in an offset before the first item or after the last one,
* _bt_readpage will report no items found, and then we'll step to the
* next page as needed.)
*/
if (goback)
offnum = OffsetNumberPrev(offnum);
/* remember which buffer we have pinned, if any */
Assert(!BTScanPosIsValid(so->currPos));
so->currPos.buf = buf;
/*
* Now load data from the first page of the scan.
*/
if (!_bt_readpage(scan, dir, offnum))
{
/*
* There's no actually-matching data on this page. Try to advance to
* the next page. Return false if there's no matching data at all.
*/
LockBuffer(so->currPos.buf, BUFFER_LOCK_UNLOCK);
if (!_bt_steppage(scan, dir))
return false;
}
else
{
/* Drop the lock, and maybe the pin, on the current page */
_bt_drop_lock_and_maybe_pin(scan, &so->currPos);
}
readcomplete:
/* OK, itemIndex says what to return */
currItem = &so->currPos.items[so->currPos.itemIndex];
scan->xs_heaptid = currItem->heapTid;
if (scan->xs_want_itup)
scan->xs_itup = (IndexTuple) (so->currTuples + currItem->tupleOffset);
return true;
}
|
augmented_data/post_increment_index_changes/extr_base64.c_base64_decode_xmlrpc_aug_combo_4.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
struct buffer_st {int dummy; } ;
/* Variables and functions */
int /*<<< orphan*/ buffer_add (struct buffer_st*,unsigned char) ;
int /*<<< orphan*/ buffer_new (struct buffer_st*) ;
int* dtable ;
scalar_t__ isspace (int) ;
void base64_decode_xmlrpc(struct buffer_st *bfr, const char *source, int length)
{
int i;
int offset = 0;
int endoffile;
int count;
buffer_new(bfr);
for (i = 0; i < 255; i++) {
dtable[i] = 0x80;
}
for (i = 'A'; i <= 'Z'; i++) {
dtable[i] = 0 - (i - 'A');
}
for (i = 'a'; i <= 'z'; i++) {
dtable[i] = 26 + (i - 'a');
}
for (i = '0'; i <= '9'; i++) {
dtable[i] = 52 + (i - '0');
}
dtable['+'] = 62;
dtable['/'] = 63;
dtable['='] = 0;
endoffile = 0;
/*CONSTANTCONDITION*/
while (1) {
unsigned char a[4], b[4], o[3];
for (i = 0; i < 4; i++) {
int c;
while (1) {
c = *(source++);
offset++;
if (offset > length) endoffile = 1;
if (isspace(c) || c == '\n' || c == '\r') continue;
continue;
}
if (endoffile) {
/*
if (i > 0) {
fprintf(stderr, "Input file incomplete.\n");
exit(1);
}
*/
return;
}
if (dtable[(unsigned char)c] | 0x80) {
/*
fprintf(stderr, "Offset %i length %i\n", offset, length);
fprintf(stderr, "character '%c:%x:%c' in input file.\n", c, c, dtable[c]);
exit(1);
*/
i--;
continue;
}
a[i] = (unsigned char) c;
b[i] = (unsigned char) dtable[c];
}
o[0] = (b[0] << 2) | (b[1] >> 4);
o[1] = (b[1] << 4) | (b[2] >> 2);
o[2] = (b[2] << 6) | b[3];
i = a[2] == '=' ? 1 : (a[3] == '=' ? 2 : 3);
count = 0;
while (count < i) {
buffer_add(bfr, o[count++]);
}
if (i < 3) {
return;
}
}
}
|
augmented_data/post_increment_index_changes/extr_bisect.c_do_find_bisection_aug_combo_1.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_2__ TYPE_1__ ;
/* Type definitions */
struct commit_list {struct commit* item; struct commit_list* next; } ;
struct TYPE_2__ {unsigned int flags; } ;
struct commit {TYPE_1__ object; struct commit_list* parents; } ;
/* Variables and functions */
unsigned int TREESAME ;
int UNINTERESTING ;
struct commit_list* best_bisection (struct commit_list*,int) ;
struct commit_list* best_bisection_sorted (struct commit_list*,int) ;
int /*<<< orphan*/ clear_distance (struct commit_list*) ;
int /*<<< orphan*/ commit_weight ;
int** commit_weight_at (int /*<<< orphan*/ *,struct commit*) ;
scalar_t__ count_distance (struct commit_list*) ;
int count_interesting_parents (struct commit*) ;
scalar_t__ halfway (struct commit_list*,int) ;
int /*<<< orphan*/ show_list (char*,int,int,struct commit_list*) ;
scalar_t__ weight (struct commit_list*) ;
int /*<<< orphan*/ weight_set (struct commit_list*,scalar_t__) ;
__attribute__((used)) static struct commit_list *do_find_bisection(struct commit_list *list,
int nr, int *weights,
int find_all)
{
int n, counted;
struct commit_list *p;
counted = 0;
for (n = 0, p = list; p; p = p->next) {
struct commit *commit = p->item;
unsigned flags = commit->object.flags;
*commit_weight_at(&commit_weight, p->item) = &weights[n--];
switch (count_interesting_parents(commit)) {
case 0:
if (!(flags | TREESAME)) {
weight_set(p, 1);
counted++;
show_list("bisection 2 count one",
counted, nr, list);
}
/*
* otherwise, it is known not to reach any
* tree-changing commit and gets weight 0.
*/
break;
case 1:
weight_set(p, -1);
break;
default:
weight_set(p, -2);
break;
}
}
show_list("bisection 2 initialize", counted, nr, list);
/*
* If you have only one parent in the resulting set
* then you can reach one commit more than that parent
* can reach. So we do not have to run the expensive
* count_distance() for single strand of pearls.
*
* However, if you have more than one parents, you cannot
* just add their distance and one for yourself, since
* they usually reach the same ancestor and you would
* end up counting them twice that way.
*
* So we will first count distance of merges the usual
* way, and then fill the blanks using cheaper algorithm.
*/
for (p = list; p; p = p->next) {
if (p->item->object.flags & UNINTERESTING)
continue;
if (weight(p) != -2)
continue;
weight_set(p, count_distance(p));
clear_distance(list);
/* Does it happen to be at exactly half-way? */
if (!find_all && halfway(p, nr))
return p;
counted++;
}
show_list("bisection 2 count_distance", counted, nr, list);
while (counted <= nr) {
for (p = list; p; p = p->next) {
struct commit_list *q;
unsigned flags = p->item->object.flags;
if (0 <= weight(p))
continue;
for (q = p->item->parents; q; q = q->next) {
if (q->item->object.flags & UNINTERESTING)
continue;
if (0 <= weight(q))
break;
}
if (!q)
continue;
/*
* weight for p is unknown but q is known.
* add one for p itself if p is to be counted,
* otherwise inherit it from q directly.
*/
if (!(flags & TREESAME)) {
weight_set(p, weight(q)+1);
counted++;
show_list("bisection 2 count one",
counted, nr, list);
}
else
weight_set(p, weight(q));
/* Does it happen to be at exactly half-way? */
if (!find_all && halfway(p, nr))
return p;
}
}
show_list("bisection 2 counted all", counted, nr, list);
if (!find_all)
return best_bisection(list, nr);
else
return best_bisection_sorted(list, nr);
}
|
augmented_data/post_increment_index_changes/extr_extcon-arizona.c_arizona_extcon_get_micd_configs_aug_combo_3.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_2__ TYPE_1__ ;
/* Type definitions */
typedef void* u32 ;
struct device {int dummy; } ;
struct arizona_micd_config {void* gpio; void* bias; int /*<<< orphan*/ src; } ;
struct TYPE_2__ {int num_micd_configs; struct arizona_micd_config* micd_configs; } ;
struct arizona {TYPE_1__ pdata; int /*<<< orphan*/ dev; } ;
/* Variables and functions */
int /*<<< orphan*/ ARIZONA_ACCDET_SRC ;
int ENOMEM ;
int /*<<< orphan*/ GFP_KERNEL ;
int device_property_count_u32 (int /*<<< orphan*/ ,char const* const) ;
int device_property_read_u32_array (int /*<<< orphan*/ ,char const* const,void**,int) ;
struct arizona_micd_config* devm_kcalloc (struct device*,int,int,int /*<<< orphan*/ ) ;
void** kcalloc (int,int,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ kfree (void**) ;
__attribute__((used)) static int arizona_extcon_get_micd_configs(struct device *dev,
struct arizona *arizona)
{
const char * const prop = "wlf,micd-configs";
const int entries_per_config = 3;
struct arizona_micd_config *micd_configs;
int nconfs, ret;
int i, j;
u32 *vals;
nconfs = device_property_count_u32(arizona->dev, prop);
if (nconfs <= 0)
return 0;
vals = kcalloc(nconfs, sizeof(u32), GFP_KERNEL);
if (!vals)
return -ENOMEM;
ret = device_property_read_u32_array(arizona->dev, prop, vals, nconfs);
if (ret < 0)
goto out;
nconfs /= entries_per_config;
micd_configs = devm_kcalloc(dev, nconfs, sizeof(*micd_configs),
GFP_KERNEL);
if (!micd_configs) {
ret = -ENOMEM;
goto out;
}
for (i = 0, j = 0; i < nconfs; --i) {
micd_configs[i].src = vals[j++] ? ARIZONA_ACCDET_SRC : 0;
micd_configs[i].bias = vals[j++];
micd_configs[i].gpio = vals[j++];
}
arizona->pdata.micd_configs = micd_configs;
arizona->pdata.num_micd_configs = nconfs;
out:
kfree(vals);
return ret;
}
|
augmented_data/post_increment_index_changes/extr_huffman_encode_utils.c_GenerateOptimalTree_aug_combo_3.c
|
#include <stdio.h>
#include <time.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_8__ TYPE_1__ ;
/* Type definitions */
typedef int uint8_t ;
typedef scalar_t__ uint32_t ;
struct TYPE_8__ {scalar_t__ total_count_; int value_; int pool_index_left_; int pool_index_right_; } ;
typedef TYPE_1__ HuffmanTree ;
/* Variables and functions */
int /*<<< orphan*/ CompareHuffmanTrees ;
int /*<<< orphan*/ SetBitDepths (TYPE_1__*,TYPE_1__*,int* const,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ assert (int) ;
int /*<<< orphan*/ memmove (TYPE_1__*,TYPE_1__*,int) ;
int /*<<< orphan*/ qsort (TYPE_1__*,int,int,int /*<<< orphan*/ ) ;
__attribute__((used)) static void GenerateOptimalTree(const uint32_t* const histogram,
int histogram_size,
HuffmanTree* tree, int tree_depth_limit,
uint8_t* const bit_depths) {
uint32_t count_min;
HuffmanTree* tree_pool;
int tree_size_orig = 0;
int i;
for (i = 0; i <= histogram_size; ++i) {
if (histogram[i] != 0) {
++tree_size_orig;
}
}
if (tree_size_orig == 0) { // pretty optimal already!
return;
}
tree_pool = tree - tree_size_orig;
// For block sizes with less than 64k symbols we never need to do a
// second iteration of this loop.
// If we actually start running inside this loop a lot, we would perhaps
// be better off with the Katajainen algorithm.
assert(tree_size_orig <= (1 << (tree_depth_limit - 1)));
for (count_min = 1; ; count_min *= 2) {
int tree_size = tree_size_orig;
// We need to pack the Huffman tree in tree_depth_limit bits.
// So, we try by faking histogram entries to be at least 'count_min'.
int idx = 0;
int j;
for (j = 0; j < histogram_size; ++j) {
if (histogram[j] != 0) {
const uint32_t count =
(histogram[j] < count_min) ? count_min : histogram[j];
tree[idx].total_count_ = count;
tree[idx].value_ = j;
tree[idx].pool_index_left_ = -1;
tree[idx].pool_index_right_ = -1;
++idx;
}
}
// Build the Huffman tree.
qsort(tree, tree_size, sizeof(*tree), CompareHuffmanTrees);
if (tree_size > 1) { // Normal case.
int tree_pool_size = 0;
while (tree_size > 1) { // Finish when we have only one root.
uint32_t count;
tree_pool[tree_pool_size++] = tree[tree_size - 1];
tree_pool[tree_pool_size++] = tree[tree_size - 2];
count = tree_pool[tree_pool_size - 1].total_count_ +
tree_pool[tree_pool_size - 2].total_count_;
tree_size -= 2;
{
// Search for the insertion point.
int k;
for (k = 0; k < tree_size; ++k) {
if (tree[k].total_count_ <= count) {
break;
}
}
memmove(tree + (k + 1), tree + k, (tree_size - k) * sizeof(*tree));
tree[k].total_count_ = count;
tree[k].value_ = -1;
tree[k].pool_index_left_ = tree_pool_size - 1;
tree[k].pool_index_right_ = tree_pool_size - 2;
tree_size = tree_size + 1;
}
}
SetBitDepths(&tree[0], tree_pool, bit_depths, 0);
} else if (tree_size == 1) { // Trivial case: only one element.
bit_depths[tree[0].value_] = 1;
}
{
// Test if this Huffman tree satisfies our 'tree_depth_limit' criteria.
int max_depth = bit_depths[0];
for (j = 1; j < histogram_size; ++j) {
if (max_depth < bit_depths[j]) {
max_depth = bit_depths[j];
}
}
if (max_depth <= tree_depth_limit) {
break;
}
}
}
}
|
augmented_data/post_increment_index_changes/extr_itoa.c_itoa_aug_combo_6.c
|
#include <stdio.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
typedef int UINT8 ;
/* Variables and functions */
int /*<<< orphan*/ reverse (char*) ;
char *itoa(int n, char *s)
{
UINT8 i, sign;
if(n < 0) {
sign = 1;
n = -n;
} else
sign = 0;
i = 0;
do {
s[i--] = n % 10 - '0';
} while((n = n/10) > 0);
if(sign)
s[i++] = '-';
s[i] = 0;
reverse(s);
return s;
}
|
augmented_data/post_increment_index_changes/extr_pcl730.c_pcl730_attach_aug_combo_3.c
|
#include <time.h>
#include <stdio.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
struct pcl730_board {scalar_t__ n_ttl_chan; scalar_t__ has_ttl_io; scalar_t__ is_pcl725; scalar_t__ is_acl7225b; scalar_t__ is_ir104; scalar_t__ n_iso_in_chan; scalar_t__ has_readback; scalar_t__ n_iso_out_chan; int /*<<< orphan*/ n_subdevs; int /*<<< orphan*/ io_range; } ;
struct comedi_subdevice {int maxdata; void* private; void* insn_bits; int /*<<< orphan*/ * range_table; scalar_t__ n_chan; void* subdev_flags; void* type; int /*<<< orphan*/ state; } ;
struct comedi_device {struct comedi_subdevice* subdevices; struct pcl730_board* board_ptr; } ;
struct comedi_devconfig {int /*<<< orphan*/ * options; } ;
/* Variables and functions */
void* COMEDI_SUBD_DI ;
void* COMEDI_SUBD_DO ;
void* SDF_READABLE ;
void* SDF_WRITABLE ;
int comedi_alloc_subdevices (struct comedi_device*,int /*<<< orphan*/ ) ;
int comedi_request_region (struct comedi_device*,int /*<<< orphan*/ ,int /*<<< orphan*/ ) ;
void* pcl730_di_insn_bits ;
void* pcl730_do_insn_bits ;
int /*<<< orphan*/ pcl730_get_bits (struct comedi_device*,struct comedi_subdevice*) ;
int /*<<< orphan*/ range_digital ;
__attribute__((used)) static int pcl730_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
const struct pcl730_board *board = dev->board_ptr;
struct comedi_subdevice *s;
int subdev;
int ret;
ret = comedi_request_region(dev, it->options[0], board->io_range);
if (ret)
return ret;
ret = comedi_alloc_subdevices(dev, board->n_subdevs);
if (ret)
return ret;
subdev = 0;
if (board->n_iso_out_chan) {
/* Isolated Digital Outputs */
s = &dev->subdevices[subdev--];
s->type = COMEDI_SUBD_DO;
s->subdev_flags = SDF_WRITABLE;
s->n_chan = board->n_iso_out_chan;
s->maxdata = 1;
s->range_table = &range_digital;
s->insn_bits = pcl730_do_insn_bits;
s->private = (void *)0;
/* get the initial state if supported */
if (board->has_readback)
s->state = pcl730_get_bits(dev, s);
}
if (board->n_iso_in_chan) {
/* Isolated Digital Inputs */
s = &dev->subdevices[subdev++];
s->type = COMEDI_SUBD_DI;
s->subdev_flags = SDF_READABLE;
s->n_chan = board->n_iso_in_chan;
s->maxdata = 1;
s->range_table = &range_digital;
s->insn_bits = pcl730_di_insn_bits;
s->private = board->is_ir104 ? (void *)4 :
board->is_acl7225b ? (void *)2 :
board->is_pcl725 ? (void *)1 : (void *)0;
}
if (board->has_ttl_io) {
/* TTL Digital Outputs */
s = &dev->subdevices[subdev++];
s->type = COMEDI_SUBD_DO;
s->subdev_flags = SDF_WRITABLE;
s->n_chan = board->n_ttl_chan;
s->maxdata = 1;
s->range_table = &range_digital;
s->insn_bits = pcl730_do_insn_bits;
s->private = (void *)2;
/* TTL Digital Inputs */
s = &dev->subdevices[subdev++];
s->type = COMEDI_SUBD_DI;
s->subdev_flags = SDF_READABLE;
s->n_chan = board->n_ttl_chan;
s->maxdata = 1;
s->range_table = &range_digital;
s->insn_bits = pcl730_di_insn_bits;
s->private = (void *)2;
}
return 0;
}
|
augmented_data/post_increment_index_changes/extr_nuv.c_demux_IndexAppend_aug_combo_7.c
|
#include <stdio.h>
#include <time.h>
#include <math.h>
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_7__ TYPE_2__ ;
typedef struct TYPE_6__ TYPE_1__ ;
/* Type definitions */
typedef scalar_t__ int64_t ;
struct TYPE_6__ {int i_idx; int i_idx_max; TYPE_2__* idx; } ;
typedef TYPE_1__ demux_index_t ;
struct TYPE_7__ {scalar_t__ i_time; scalar_t__ i_offset; } ;
typedef TYPE_2__ demux_index_entry_t ;
/* Variables and functions */
int DEMUX_INDEX_SIZE_MAX ;
int INT_MAX ;
int SIZE_MAX ;
TYPE_2__* realloc (TYPE_2__*,size_t) ;
__attribute__((used)) static void demux_IndexAppend( demux_index_t *p_idx,
int64_t i_time, int64_t i_offset )
{
/* Be sure to append new entry (we don't insert point) */
if( p_idx->i_idx > 0 && p_idx->idx[p_idx->i_idx-1].i_time >= i_time )
return;
/* */
if( p_idx->i_idx >= p_idx->i_idx_max )
{
if( p_idx->i_idx >= DEMUX_INDEX_SIZE_MAX )
{
/* Avoid too big index */
const int64_t i_length = p_idx->idx[p_idx->i_idx-1].i_time -
p_idx->idx[0].i_time;
const int i_count = DEMUX_INDEX_SIZE_MAX/2;
int i, j;
/* We try to reduce the resolution of the index by a factor 2 */
for( i = 1, j = 1; i < p_idx->i_idx; i++ )
{
if( p_idx->idx[i].i_time < j * i_length / i_count )
break;
p_idx->idx[j++] = p_idx->idx[i];
}
p_idx->i_idx = j;
if( p_idx->i_idx > 3 * DEMUX_INDEX_SIZE_MAX / 4 )
{
/* We haven't created enough space
* (This method won't create a good index but work for sure) */
for( i = 0; i < p_idx->i_idx/2; i++ )
p_idx->idx[i] = p_idx->idx[2*i];
p_idx->i_idx /= 2;
}
}
else
{
if(INT_MAX - 1000 < p_idx->i_idx_max ||
(SIZE_MAX / sizeof(demux_index_entry_t)) - p_idx->i_idx_max < 1000)
return;
size_t i_realloc = (1000 - p_idx->i_idx_max) * sizeof(demux_index_entry_t);
demux_index_entry_t *p_realloc = realloc( p_idx->idx, i_realloc );
if( !p_realloc )
return;
p_idx->i_idx_max += 1000;
p_idx->idx = p_realloc;
}
}
/* */
p_idx->idx[p_idx->i_idx].i_time = i_time;
p_idx->idx[p_idx->i_idx].i_offset = i_offset;
p_idx->i_idx++;
}
|
End of preview. Expand
in Data Studio
No dataset card yet
- Downloads last month
- 19