<commit_before>#include "ruby.h"
#include "rubyspec.h"

#include <string.h>

#ifdef __cplusplus
extern "C" {
#endif

#if defined(HAVE_RDATA) && defined(HAVE_DATA_WRAP_STRUCT)
struct sample_wrapped_struct {
    int foo;
};

void sample_wrapped_struct_free(void* st) {
  free(st);
}

void sample_wrapped_struct_mark(void* st) {
}

VALUE sdaf_alloc_func(VALUE klass) {
  struct sample_wrapped_struct* bar = (struct sample_wrapped_struct *)malloc(sizeof(struct sample_wrapped_struct));
  bar->foo = 42;
  return Data_Wrap_Struct(klass, &sample_wrapped_struct_mark, &sample_wrapped_struct_free, bar);
}

VALUE sdaf_get_struct(VALUE self) {
  struct sample_wrapped_struct* bar;
  Data_Get_Struct(self, struct sample_wrapped_struct, bar);

  return INT2FIX((*bar).foo);
}

VALUE sws_wrap_struct(VALUE self, VALUE val) {
  struct sample_wrapped_struct* bar = (struct sample_wrapped_struct *)malloc(sizeof(struct sample_wrapped_struct));
  bar->foo = FIX2INT(val);
  return Data_Wrap_Struct(rb_cObject, &sample_wrapped_struct_mark, &sample_wrapped_struct_free, bar);
}

VALUE sws_get_struct(VALUE self, VALUE obj) {
  struct sample_wrapped_struct* bar;
  Data_Get_Struct(obj, struct sample_wrapped_struct, bar);

  return INT2FIX((*bar).foo);
}

VALUE sws_get_struct_rdata(VALUE self, VALUE obj) {
  struct sample_wrapped_struct* bar;
  bar = (struct sample_wrapped_struct*) RDATA(obj)->data;
  return INT2FIX(bar->foo);
}

VALUE sws_get_struct_data_ptr(VALUE self, VALUE obj) {
  struct sample_wrapped_struct* bar;
  bar = (struct sample_wrapped_struct*) DATA_PTR(obj);
  return INT2FIX(bar->foo);
}

VALUE sws_change_struct(VALUE self, VALUE obj, VALUE new_val) {
  struct sample_wrapped_struct *old_struct, *new_struct;
  new_struct = (struct sample_wrapped_struct *)malloc(sizeof(struct sample_wrapped_struct));
  new_struct->foo = FIX2INT(new_val);
  old_struct = RDATA(obj)->data;
  free(old_struct);
  RDATA(obj)->data = new_struct;<commit_msg>Remove redundant casts<commit_after>#include "ruby.h"
#include "rubyspec.h"

#include <string.h>

#ifdef __cplusplus
extern "C" {
#endif

#if defined(HAVE_RDATA) && defined(HAVE_DATA_WRAP_STRUCT)
struct sample_wrapped_struct {
    int foo;
};

void sample_wrapped_struct_free(void* st) {
  free(st);
}

void sample_wrapped_struct_mark(void* st) {
}

VALUE sdaf_alloc_func(VALUE klass) {
  struct sample_wrapped_struct* bar = malloc(sizeof(struct sample_wrapped_struct));
  bar->foo = 42;
  return Data_Wrap_Struct(klass, &sample_wrapped_struct_mark, &sample_wrapped_struct_free, bar);
}

VALUE sdaf_get_struct(VALUE self) {
  struct sample_wrapped_struct* bar;
  Data_Get_Struct(self, struct sample_wrapped_struct, bar);

  return INT2FIX((*bar).foo);
}

VALUE sws_wrap_struct(VALUE self, VALUE val) {
  struct sample_wrapped_struct* bar = malloc(sizeof(struct sample_wrapped_struct));
  bar->foo = FIX2INT(val);
  return Data_Wrap_Struct(rb_cObject, &sample_wrapped_struct_mark, &sample_wrapped_struct_free, bar);
}

VALUE sws_get_struct(VALUE self, VALUE obj) {
  struct sample_wrapped_struct* bar;
  Data_Get_Struct(obj, struct sample_wrapped_struct, bar);

  return INT2FIX((*bar).foo);
}

VALUE sws_get_struct_rdata(VALUE self, VALUE obj) {
  struct sample_wrapped_struct* bar;
  bar = (struct sample_wrapped_struct*) RDATA(obj)->data;
  return INT2FIX(bar->foo);
}

VALUE sws_get_struct_data_ptr(VALUE self, VALUE obj) {
  struct sample_wrapped_struct* bar;
  bar = (struct sample_wrapped_struct*) DATA_PTR(obj);
  return INT2FIX(bar->foo);
}

VALUE sws_change_struct(VALUE self, VALUE obj, VALUE new_val) {
  struct sample_wrapped_struct *old_struct, *new_struct;
  new_struct = malloc(sizeof(struct sample_wrapped_struct));
  new_struct->foo = FIX2INT(new_val);
  old_struct = RDATA(obj)->data;
  free(old_struct);
  RDATA(obj)->data = new_struct;
{'fraction_non_alphanumeric': 0.11087700816434026, 'fraction_numerical': 0.004213853041875165, 'mean_word_length': 6.672727272727273, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4713166', 'n_tokens_mistral': 1404, 'n_tokens_neox': 1386, 'n_words': 271}