<commit_before>package datatype

/*
#cgo pkg-config: libqrencode
#include <stdlib.h>
#include <qrencode.h>
*/
import "C"

import "unsafe"

var origList *C.QRcode_List
var qrcodeList *C.QRcode_List
var qrcode *QRcode

// CreateQRCodes creates multiple QR Codes using structured append
func CreateQRCodes(data []byte) {
	qrcodeList = C.QRcode_encodeDataStructured(C.int(len(data)), (*C.uchar)(unsafe.Pointer(&data[0])), C.int(40), C.QR_ECLEVEL_L)
	origList = qrcodeList
}

// Next increments QRcode_List pointer to the next element
func Next() {
	qrcodeList = (*C.QRcode_List)(qrcodeList.next)
	qrcode = nil
	Code()
}

// Code returns a QRcode struct of the QR Code
func Code() *QRcode {
	if qrcodeList == nil {
		return nil
	}

	if qrcode == nil {
		qrcode = CreateQRCode(qrcodeList.code)
	}

	return qrcode
}

// Size returns the size of the QR Code List
func Size() int {
	return int(C.QRcode_List_size(qrcodeList))
}

// Free frees the QR Code List
func Free() {<commit_msg>Split data and recursively add to list if data is too large<commit_after>package datatype

/*
#cgo pkg-config: libqrencode
#include <stdlib.h>
#include <qrencode.h>
*/
import "C"

import (
	"syscall"
	"unsafe"
)

var origList *C.QRcode_List
var qrcodeList *C.QRcode_List
var qrcode *QRcode

// CreateQRCodes creates multiple QR Codes using structured append
func CreateQRCodes(data []byte) {
	a, err := C.QRcode_encodeDataStructured(C.int(len(data)), (*C.uchar)(unsafe.Pointer(&data[0])), C.int(40), C.QR_ECLEVEL_L)

	// If data too large
	if err == syscall.ERANGE {
		split(data)
	} else {
		qrcodeList = a
		origList = qrcodeList
	}
}

// Split list and recursively build onto a new one
func split(data []byte) {
	size := len(data) / 2
	var mainList *C.QRcode_List
	CreateQRCodes(data[:size])
	mainList = qrcodeList
	tempList := mainList

	CreateQRCodes(data[size-1 : len(data)])
	for tempList.next != nil {
		tempList = (*C.QRcode_List)(tempList.next)
	}
	for qrcodeList != nil {
		tempList.next = qrcodeList.next
		tempList = (*C.QRcode_List)(tempList.next)
		qrcodeList = (*C.QRcode_List)(qrcodeList.next)
	}
	qrcodeList = mainList
	origList = mainList
}

// Next increments QRcode_List pointer to the next element
func Next() {
	qrcodeList = (*C.QRcode_List)(qrcodeList.next)
	qrcode = nil
	Code()
}

// Code returns a QRcode struct of the QR Code
func Code() *QRcode {
	if qrcodeList == nil {
		return nil
	}

	if qrcode == nil {
		qrcode = CreateQRCode(qrcodeList.code)
	}

	return qrcode
}

// Size returns the size of the QR Code List
func Size() int {
	return int(C.QRcode_List_size(qrcodeList))
}

// Free frees the QR Code List
func Free() {
{'fraction_non_alphanumeric': 0.12129277566539924, 'fraction_numerical': 0.003041825095057034, 'mean_word_length': 4.199604743083004, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2448651', 'n_tokens_mistral': 1065, 'n_tokens_neox': 977, 'n_words': 269}