1 From 6a7cb95c5af4537bad72bad9b190e09cb6d7883c Mon Sep 17 00:00:00 2001
2 From: cexen <cexenial@gmail.com>
3 Date: Sun, 21 Jan 2024 21:01:29 +0900
4 Subject: [PATCH] replace PyMem_* to PyMem_Raw*
8 c_src/posix_mutex.c | 4 ++--
9 c_src/simpleaudio.c | 8 ++++----
10 c_src/simpleaudio_win.c | 8 ++++----
11 3 files changed, 10 insertions(+), 10 deletions(-)
13 diff --git a/c_src/posix_mutex.c b/c_src/posix_mutex.c
14 index 533a3f1..04619f1 100644
15 --- a/c_src/posix_mutex.c
16 +++ b/c_src/posix_mutex.c
17 @@ -10,14 +10,14 @@ MIT License (see LICENSE.txt)
19 void* create_mutex() {
21 - mutex = PyMem_Malloc(sizeof(pthread_mutex_t));
22 + mutex = PyMem_RawMalloc(sizeof(pthread_mutex_t));
23 pthread_mutex_init((pthread_mutex_t*)mutex, NULL);
27 void destroy_mutex(void* mutex) {
28 pthread_mutex_destroy((pthread_mutex_t*)mutex);
30 + PyMem_RawFree(mutex);
33 void grab_mutex(void* mutex) {
34 diff --git a/c_src/simpleaudio.c b/c_src/simpleaudio.c
35 index edacba3..b0b24b8 100644
36 --- a/c_src/simpleaudio.c
37 +++ b/c_src/simpleaudio.c
38 @@ -219,7 +219,7 @@ void delete_list_item(play_item_t* play_item) {
39 play_item->prev_item->next_item = play_item->next_item;
41 destroy_mutex(play_item->mutex);
42 - PyMem_Free(play_item);
43 + PyMem_RawFree(play_item);
46 /*********************************************/
47 @@ -228,7 +228,7 @@ play_item_t* new_list_item(play_item_t* list_head) {
48 play_item_t* new_item;
49 play_item_t* old_tail;
51 - new_item = PyMem_Malloc(sizeof(play_item_t));
52 + new_item = PyMem_RawMalloc(sizeof(play_item_t));
53 new_item->next_item = NULL;
56 @@ -269,13 +269,13 @@ void destroy_audio_blob(audio_blob_t* audio_blob) {
57 grab_mutex(audio_blob->list_mutex);
58 delete_list_item(audio_blob->play_list_item);
59 release_mutex(audio_blob->list_mutex);
60 - PyMem_Free(audio_blob);
61 + PyMem_RawFree(audio_blob);
64 /********************************************/
66 audio_blob_t* create_audio_blob() {
67 - audio_blob_t* audio_blob = PyMem_Malloc(sizeof(audio_blob_t));
68 + audio_blob_t* audio_blob = PyMem_RawMalloc(sizeof(audio_blob_t));
70 dbg1("created audio blob at %p\n", audio_blob);
72 diff --git a/c_src/simpleaudio_win.c b/c_src/simpleaudio_win.c
73 index 5aed022..ba79d23 100644
74 --- a/c_src/simpleaudio_win.c
75 +++ b/c_src/simpleaudio_win.c
76 @@ -57,8 +57,8 @@ MMRESULT fill_buffer(WAVEHDR* wave_header, audio_blob_t* audio_blob) {
77 if (audio_blob->num_buffers > 0) {
78 dbg2("done buffering - dellocating a buffer\n");
80 - PyMem_Free(wave_header->lpData);
81 - PyMem_Free(wave_header);
82 + PyMem_RawFree(wave_header->lpData);
83 + PyMem_RawFree(wave_header);
84 audio_blob->num_buffers--;
86 if (audio_blob->num_buffers == 0) {
87 @@ -182,9 +182,9 @@ PyObject* play_os(Py_buffer buffer_obj, int len_samples, int num_channels, int b
88 dbg1("allocating %d buffers of %d bytes\n", NUM_BUFS, buffer_size);
90 for (i = 0; i < NUM_BUFS; i++) {
91 - temp_wave_hdr = PyMem_Malloc(sizeof(WAVEHDR));
92 + temp_wave_hdr = PyMem_RawMalloc(sizeof(WAVEHDR));
93 memset(temp_wave_hdr, 0, sizeof(WAVEHDR));
94 - temp_wave_hdr->lpData = PyMem_Malloc(buffer_size);
95 + temp_wave_hdr->lpData = PyMem_RawMalloc(buffer_size);
96 temp_wave_hdr->dwBufferLength = buffer_size;
98 result = fill_buffer(temp_wave_hdr, audio_blob);