use PyObject_New() for object instanziation

This commit is contained in:
Nico von Geyso
2013-03-12 15:31:04 +01:00
parent cd07b9edac
commit f97f58ec56
3 changed files with 5 additions and 4 deletions

View File

@@ -58,7 +58,7 @@ diff_get_patch_byindex(git_diff_list* list, size_t idx)
if (err < 0) if (err < 0)
return Error_set(err); return Error_set(err);
py_patch = (Patch*) PyType_GenericNew(&PatchType, NULL, NULL); py_patch = PyObject_New(Patch, &PatchType);
if (py_patch != NULL) { if (py_patch != NULL) {
py_patch->old_file_path = delta->old_file.path; py_patch->old_file_path = delta->old_file.path;
py_patch->new_file_path = delta->new_file.path; py_patch->new_file_path = delta->new_file.path;
@@ -77,7 +77,7 @@ diff_get_patch_byindex(git_diff_list* list, size_t idx)
if (err < 0) if (err < 0)
goto cleanup; goto cleanup;
py_hunk = (Hunk*)PyType_GenericNew(&HunkType, NULL, NULL); py_hunk = PyObject_New(Hunk, &HunkType);
if (py_hunk != NULL) { if (py_hunk != NULL) {
py_hunk->old_start = range->old_start; py_hunk->old_start = range->old_start;
py_hunk->old_lines = range->old_lines; py_hunk->old_lines = range->old_lines;

View File

@@ -172,6 +172,7 @@ NoteIter_iternext(NoteIter *self)
void void
NoteIter_dealloc(NoteIter *self) NoteIter_dealloc(NoteIter *self)
{ {
Py_CLEAR(self->repo);
git_note_iterator_free(self->iter); git_note_iterator_free(self->iter);
PyObject_Del(self); PyObject_Del(self);
} }
@@ -216,7 +217,7 @@ wrap_note(Repository* repo, git_oid* annotated_id, const char* ref)
Note* py_note = NULL; Note* py_note = NULL;
int err = GIT_ERROR; int err = GIT_ERROR;
py_note = (Note*) PyType_GenericNew(&NoteType, NULL, NULL); py_note = PyObject_New(Note, &NoteType);
if (py_note == NULL) { if (py_note == NULL) {
PyErr_NoMemory(); PyErr_NoMemory();
return NULL; return NULL;

View File

@@ -1053,7 +1053,7 @@ Repository_create_remote(Repository *self, PyObject *args)
if (err < 0) if (err < 0)
return Error_set(err); return Error_set(err);
py_remote = (Remote*) PyType_GenericNew(&RemoteType, NULL, NULL); py_remote = PyObject_New(Remote, &RemoteType);
py_remote->repo = self; py_remote->repo = self;
py_remote->remote = remote; py_remote->remote = remote;