<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenCV.Net.Native;
using System.Runtime.InteropServices;

namespace OpenCV.Net
{
    public class IplImage : CvArr
    {
        bool ownsData;

        internal IplImage()
        {
            ownsData = true;
        }

        internal IplImage(IntPtr handle, bool ownsHandle)
            : base(ownsHandle)
        {
            SetHandle(handle);
            ownsData = true;
        }

        public IplImage(CvSize size, int depth, int channels)
        {
            var pImage = core.cvCreateImage(size, depth, channels);
            SetHandle(pImage);

            GC.AddMemoryPressure(WidthStep * Height * depth / 8);
            ownsData = true;
        }

        public IplImage(CvSize size, int depth, int channels, IntPtr data)
        {
            var pImage = core.cvCreateImageHeader(size, depth, channels);
            SetHandle(pImage);

            SetData(data, WidthStep);
            ownsData = false;
        }

        public CvRect ImageROI
        {
            get { return core.cvGetImageROI(this); }
            set { core.cvSetImageROI(this, value); }
        }

        public int Width
        {<commit_msg>Fixed bug in internal allocation of IplImage leading to out-of-memory errors.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenCV.Net.Native;
using System.Runtime.InteropServices;

namespace OpenCV.Net
{
    public class IplImage : CvArr
    {
        bool ownsData;

        internal IplImage()
        {
            ownsData = true;
        }

        internal IplImage(IntPtr handle, bool ownsHandle)
            : base(ownsHandle)
        {
            SetHandle(handle);

            GC.AddMemoryPressure(WidthStep * Height * Depth / 8);
            ownsData = true;
        }

        public IplImage(CvSize size, int depth, int channels)
        {
            var pImage = core.cvCreateImage(size, depth, channels);
            SetHandle(pImage);

            GC.AddMemoryPressure(WidthStep * Height * Depth / 8);
            ownsData = true;
        }

        public IplImage(CvSize size, int depth, int channels, IntPtr data)
        {
            var pImage = core.cvCreateImageHeader(size, depth, channels);
            SetHandle(pImage);

            SetData(data, WidthStep);
            ownsData = false;
        }

        public CvRect ImageROI
        {
            get { return core.cvGetImageROI(this); }
            set { core.cvSetImageROI(this, value); }
        }

        public int Width
        {
{'fraction_non_alphanumeric': 0.08418657565415244, 'fraction_numerical': 0.0011376564277588168, 'mean_word_length': 1.7944915254237288, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1320000', 'n_tokens_mistral': 758, 'n_tokens_neox': 740, 'n_words': 180}