<commit_before>/* $Id: curl.c,v 1.63 2002/04/15 13:14:25 kjetilja Exp $ */

/* cURL Python module by <NAME> <<EMAIL>> */

#include "Python.h"
#include <curl/curl.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>

/* Ensure we have an updated libcurl */
#if LIBCURL_VERSION_NUM < 0x070906
  #error "Need libcurl version 7.9.6 or greater to compile pycurl."
#endif

static PyObject *ErrorObject;

typedef struct {
    PyObject_HEAD
    CURL *handle;
    struct HttpPost *httppost;
    struct curl_slist *httpheader;
    struct curl_slist *quote;
    struct curl_slist *postquote;
    struct curl_slist *prequote;
    PyObject *w_cb;
    PyObject *h_cb;
    PyObject *r_cb;
    PyObject *pro_cb;
    PyObject *pwd_cb;
    PyObject *d_cb;
    PyThreadState *state;
    int writeheader_set;
    char error[CURL_ERROR_SIZE];
    void *options[CURLOPT_LASTENTRY];
} CurlObject;

#if !defined(__cplusplus)
staticforward PyTypeObject Curl_Type;
#endif

#define CURLERROR() \
{\
    PyObject *v; \
    v = Py_BuildValue("(is)", res, self->error); \
    PyErr_SetObject(ErrorObject, v); \
    Py_DECREF(v); \
    return NULL; \
}

/* --------------------------------------------------------------------- */

static void
self_cleanup(CurlObject *self)
{
    int i;

    if (self->handle != NULL) {
        Py_BEGIN_ALLOW_THREADS
	curl_easy_cleanup(self->handle);
        Py_END_ALLOW_THREADS
        self->handle = NULL;
    }
    if (self->httpheader != NULL) {
	curl_slist_free_all(self->httpheader);
	self->httpheader = NULL;
    }
    if (self->quote != NULL) {
	curl_slist_free_all(self->quote);
	self->quote = NULL;
    }
    if (self->postquote != NULL) {
	curl_slist_free_all(self->postquote);
	self->postquote = NULL;
    }
    if (self->prequote != NULL) {
	curl_slist_free_all(self->prequote);
	self->prequote = NULL;
    }
    if (self->httppost != NULL) {
	curl_formfree(self->httppost);<commit_msg>fixed a bug in curlobject deallocation for python1.5.2<commit_after>/* $Id: curl.c,v 1.64 2002/04/15 14:13:06 kjetilja Exp $ */

/* cURL Python module by <NAME> <<EMAIL>> */

#include "Python.h"
#include <curl/curl.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>

/* Ensure we have an updated libcurl */
#if LIBCURL_VERSION_NUM < 0x070906
  #error "Need libcurl version 7.9.6 or greater to compile pycurl."
#endif

static PyObject *ErrorObject;

typedef struct {
    PyObject_HEAD
    CURL *handle;
    struct HttpPost *httppost;
    struct curl_slist *httpheader;
    struct curl_slist *quote;
    struct curl_slist *postquote;
    struct curl_slist *prequote;
    PyObject *w_cb;
    PyObject *h_cb;
    PyObject *r_cb;
    PyObject *pro_cb;
    PyObject *pwd_cb;
    PyObject *d_cb;
    PyThreadState *state;
    int writeheader_set;
    char error[CURL_ERROR_SIZE];
    void *options[CURLOPT_LASTENTRY];
} CurlObject;

#if !defined(__cplusplus)
staticforward PyTypeObject Curl_Type;
#endif

#define CURLERROR() \
{\
    PyObject *v; \
    v = Py_BuildValue("(is)", res, self->error); \
    PyErr_SetObject(ErrorObject, v); \
    Py_DECREF(v); \
    return NULL; \
}

/* --------------------------------------------------------------------- */

static void
self_cleanup(CurlObject *self)
{
    int i;

    if (self->handle == NULL) {
        return;
    }
    if (self->handle != NULL) {
        Py_BEGIN_ALLOW_THREADS
	curl_easy_cleanup(self->handle);
        Py_END_ALLOW_THREADS
        self->handle = NULL;
    }
    if (self->httpheader != NULL) {
	curl_slist_free_all(self->httpheader);
	self->httpheader = NULL;
    }
    if (self->quote != NULL) {
	curl_slist_free_all(self->quote);
	self->quote = NULL;
    }
    if (self->postquote != NULL) {
	curl_slist_free_all(self->postquote);
	self->postquote = NULL;
    }
    if (self->prequote != NULL) {
	curl_slist_free_all(self->prequote);
	self->prequote = NULL;
    }
    if (self->httppost != NULL) {
	curl_formfree(self->httppost);
{'fraction_non_alphanumeric': 0.16393028542561253, 'fraction_numerical': 0.014397575145238697, 'mean_word_length': 2.8899803536345776, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 56, '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': '1937637', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1437, 'n_words': 312}