mirror of
https://github.com/Goldenkrew3000/OSSP_OpenSource.git
synced 2025-12-18 15:54:44 +10:00
Fixed malloc() by not casting void*
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
// Returns 1 if failure occured, else 0
|
||||
int opensubsonic_getAlbum_parse(char* data, opensubsonic_getAlbum_struct** getAlbumStruct) {
|
||||
// Allocate and initialize
|
||||
(*getAlbumStruct) = (opensubsonic_getAlbum_struct*)malloc(sizeof(opensubsonic_getAlbum_struct));
|
||||
(*getAlbumStruct) = malloc(sizeof(opensubsonic_getAlbum_struct));
|
||||
(*getAlbumStruct)->status = NULL;
|
||||
(*getAlbumStruct)->errorCode = 0;
|
||||
(*getAlbumStruct)->errorMessage = NULL;
|
||||
@@ -93,7 +93,7 @@ int opensubsonic_getAlbum_parse(char* data, opensubsonic_getAlbum_struct** getAl
|
||||
(*getAlbumStruct)->songCount = cJSON_GetArraySize(song_root);
|
||||
|
||||
// Allocate and initialize
|
||||
(*getAlbumStruct)->songs = (opensubsonic_getAlbum_song_struct*)malloc((*getAlbumStruct)->songCount * sizeof(opensubsonic_getAlbum_song_struct));
|
||||
(*getAlbumStruct)->songs = malloc((*getAlbumStruct)->songCount * sizeof(opensubsonic_getAlbum_song_struct));
|
||||
|
||||
for (int i = 0; i < (*getAlbumStruct)->songCount; i++) {
|
||||
(*getAlbumStruct)->songs[i].id = NULL;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// Returns 1 if failure occured, else 0
|
||||
int opensubsonic_getAlbumList_parse(char* data, opensubsonic_getAlbumList_struct** getAlbumListStruct) {
|
||||
// Allocate struct and initialize variables
|
||||
(*getAlbumListStruct) = (opensubsonic_getAlbumList_struct*)malloc(sizeof(opensubsonic_getAlbumList_struct));
|
||||
(*getAlbumListStruct) = malloc(sizeof(opensubsonic_getAlbumList_struct));
|
||||
(*getAlbumListStruct)->status = NULL;
|
||||
(*getAlbumListStruct)->errorCode = 0;
|
||||
(*getAlbumListStruct)->errorMessage = NULL;
|
||||
@@ -70,7 +70,7 @@ int opensubsonic_getAlbumList_parse(char* data, opensubsonic_getAlbumList_struct
|
||||
(*getAlbumListStruct)->albumCount = cJSON_GetArraySize(album_root);
|
||||
|
||||
// Allocate and initialize
|
||||
(*getAlbumListStruct)->albums = (opensubsonic_getAlbumList_album_struct*)malloc((*getAlbumListStruct)->albumCount * sizeof(opensubsonic_getAlbumList_album_struct));
|
||||
(*getAlbumListStruct)->albums = malloc((*getAlbumListStruct)->albumCount * sizeof(opensubsonic_getAlbumList_album_struct));
|
||||
for (int i = 0; i < (*getAlbumListStruct)->albumCount; i++) {
|
||||
(*getAlbumListStruct)->albums[i].id = NULL;
|
||||
(*getAlbumListStruct)->albums[i].parent = NULL;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
// Returns 1 if failure occured, else 0
|
||||
int opensubsonic_getArtist_parse(char* data, opensubsonic_getArtist_struct** getArtistStruct) {
|
||||
// Allocate struct
|
||||
*getArtistStruct = (opensubsonic_getArtist_struct*)malloc(sizeof(opensubsonic_getArtist_struct));
|
||||
*getArtistStruct = malloc(sizeof(opensubsonic_getArtist_struct));
|
||||
|
||||
// Initialize struct variables
|
||||
(*getArtistStruct)->status = NULL;
|
||||
@@ -89,7 +89,7 @@ int opensubsonic_getArtist_parse(char* data, opensubsonic_getArtist_struct** get
|
||||
(*getArtistStruct)->albumCount = cJSON_GetArraySize(album_root);
|
||||
|
||||
// Allocate memory for albums
|
||||
(*getArtistStruct)->albums = (opensubsonic_getArtist_album_struct*)malloc((*getArtistStruct)->albumCount * sizeof(opensubsonic_getArtist_album_struct));
|
||||
(*getArtistStruct)->albums = malloc((*getArtistStruct)->albumCount * sizeof(opensubsonic_getArtist_album_struct));
|
||||
|
||||
// Initialize variables
|
||||
for (int i = 0; i < (*getArtistStruct)->albumCount; i++) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
// Returns 1 if failure occured, else 0
|
||||
int opensubsonic_getArtists_parse(char* data, opensubsonic_getArtists_struct** getArtistsStruct) {
|
||||
// Allocate struct
|
||||
*getArtistsStruct = (opensubsonic_getArtists_struct*)malloc(sizeof(opensubsonic_getArtists_struct));
|
||||
*getArtistsStruct = malloc(sizeof(opensubsonic_getArtists_struct));
|
||||
|
||||
// Initialize struct variables
|
||||
(*getArtistsStruct)->status = NULL;
|
||||
@@ -91,7 +91,7 @@ int opensubsonic_getArtists_parse(char* data, opensubsonic_getArtists_struct** g
|
||||
}
|
||||
|
||||
// Allocate memory for opensubsonic_getArtists_artist_struct inside opensubsonic_getArtists_struct (Where the artist data is held)
|
||||
(*getArtistsStruct)->artists = (opensubsonic_getArtists_artist_struct*)malloc((*getArtistsStruct)->artistCount * sizeof(opensubsonic_getArtists_artist_struct));
|
||||
(*getArtistsStruct)->artists = malloc((*getArtistsStruct)->artistCount * sizeof(opensubsonic_getArtists_artist_struct));
|
||||
|
||||
// Initialize struct variables
|
||||
for (int i = 0; i < (*getArtistsStruct)->artistCount; i++) {
|
||||
|
||||
@@ -94,7 +94,7 @@ int opensubsonic_getLyricsBySongId_parse(char* data, opensubsonic_getLyricsBySon
|
||||
|
||||
// Count amount of objects in 'line' and allocate memory
|
||||
(*getLyricsBySongIdStruct)->lyricsAmount = cJSON_GetArraySize(line_root);
|
||||
(*getLyricsBySongIdStruct)->lyrics = (opensubsonic_getLyricsBySongId_lyric_struct*)malloc((*getLyricsBySongIdStruct)->lyricsAmount * sizeof(opensubsonic_getLyricsBySongId_lyric_struct));
|
||||
(*getLyricsBySongIdStruct)->lyrics = malloc((*getLyricsBySongIdStruct)->lyricsAmount * sizeof(opensubsonic_getLyricsBySongId_lyric_struct));
|
||||
|
||||
// Initialize variables
|
||||
for (int i = 0; i < (*getLyricsBySongIdStruct)->lyricsAmount; i++) {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
int opensubsonic_getPlaylist_parse(char* data, opensubsonic_getPlaylist_struct** getPlaylistStruct) {
|
||||
// Allocate struct
|
||||
*getPlaylistStruct = (opensubsonic_getPlaylist_struct*)malloc(sizeof(opensubsonic_getPlaylist_struct));
|
||||
*getPlaylistStruct = malloc(sizeof(opensubsonic_getPlaylist_struct));
|
||||
|
||||
// Initialize struct variables
|
||||
(*getPlaylistStruct)->status = NULL;
|
||||
@@ -87,7 +87,7 @@ int opensubsonic_getPlaylist_parse(char* data, opensubsonic_getPlaylist_struct**
|
||||
|
||||
// Get the amount of songs in the playlist, and allocate memory
|
||||
(*getPlaylistStruct)->songCount = cJSON_GetArraySize(entry_root);
|
||||
(*getPlaylistStruct)->songs = (opensubsonic_getPlaylist_songs_struct*)malloc((*getPlaylistStruct)->songCount * sizeof(opensubsonic_getPlaylist_songs_struct));
|
||||
(*getPlaylistStruct)->songs = malloc((*getPlaylistStruct)->songCount * sizeof(opensubsonic_getPlaylist_songs_struct));
|
||||
|
||||
// Initialize struct variables
|
||||
for (int i = 0; i < (*getPlaylistStruct)->songCount; i++) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
// Returns 1 if failure occured, else 0
|
||||
int opensubsonic_getPlaylists_parse(char* data, opensubsonic_getPlaylists_struct** getPlaylistsStruct) {
|
||||
// Allocate struct
|
||||
*getPlaylistsStruct = (opensubsonic_getPlaylists_struct*)malloc(sizeof(opensubsonic_getPlaylists_struct));
|
||||
*getPlaylistsStruct = malloc(sizeof(opensubsonic_getPlaylists_struct));
|
||||
|
||||
// Initialize struct variables
|
||||
(*getPlaylistsStruct)->status = NULL;
|
||||
@@ -76,7 +76,7 @@ int opensubsonic_getPlaylists_parse(char* data, opensubsonic_getPlaylists_struct
|
||||
(*getPlaylistsStruct)->playlistCount = cJSON_GetArraySize(playlist_root);
|
||||
|
||||
// Allocate memory for opensubsonic_getPlaylists_playlist_struct inside opensubsonic_getPlaylists_struct
|
||||
(*getPlaylistsStruct)->playlists = (opensubsonic_getPlaylists_playlist_struct*)malloc((*getPlaylistsStruct)->playlistCount * sizeof(opensubsonic_getPlaylists_playlist_struct));
|
||||
(*getPlaylistsStruct)->playlists = malloc((*getPlaylistsStruct)->playlistCount * sizeof(opensubsonic_getPlaylists_playlist_struct));
|
||||
|
||||
// Initialize struct variables
|
||||
for (int i = 0; i < (*getPlaylistsStruct)->playlistCount; i++) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
// Returns 1 if failure occured, else 0
|
||||
int opensubsonic_getSong_parse(char* data, opensubsonic_getSong_struct** getSongStruct) {
|
||||
// Allocate struct
|
||||
*getSongStruct = (opensubsonic_getSong_struct*)malloc(sizeof(opensubsonic_getSong_struct));
|
||||
*getSongStruct = malloc(sizeof(opensubsonic_getSong_struct));
|
||||
|
||||
// Initialize struct variables
|
||||
(*getSongStruct)->status = NULL;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// Returns 1 if failure occured, else 0
|
||||
int opensubsonic_getStarred_parse(char* data, opensubsonic_getStarred_struct** getStarredStruct) {
|
||||
// Allocate and initialize
|
||||
*getStarredStruct = (opensubsonic_getStarred_struct*)malloc(sizeof(opensubsonic_getStarred_struct));
|
||||
*getStarredStruct = malloc(sizeof(opensubsonic_getStarred_struct));
|
||||
(*getStarredStruct)->status = NULL;
|
||||
(*getStarredStruct)->errorMessage = NULL;
|
||||
(*getStarredStruct)->errorCode = 0;
|
||||
@@ -86,7 +86,7 @@ int opensubsonic_getStarred_parse(char* data, opensubsonic_getStarred_struct** g
|
||||
if ((*getStarredStruct)->artistCount != -1) {
|
||||
// Count, allocate, initialize, and extract
|
||||
(*getStarredStruct)->artistCount = cJSON_GetArraySize(artist_root);
|
||||
(*getStarredStruct)->artists = (opensubsonic_getStarred_artist_struct*)malloc((*getStarredStruct)->artistCount * sizeof(opensubsonic_getStarred_artist_struct));
|
||||
(*getStarredStruct)->artists = malloc((*getStarredStruct)->artistCount * sizeof(opensubsonic_getStarred_artist_struct));
|
||||
|
||||
for (int i = 0; i < (*getStarredStruct)->artistCount; i++) {
|
||||
(*getStarredStruct)->artists[i].id = NULL;
|
||||
@@ -113,7 +113,7 @@ int opensubsonic_getStarred_parse(char* data, opensubsonic_getStarred_struct** g
|
||||
if ((*getStarredStruct)->albumCount != -1) {
|
||||
// Count, allocate, initialize, and extract
|
||||
(*getStarredStruct)->albumCount = cJSON_GetArraySize(album_root);
|
||||
(*getStarredStruct)->albums = (opensubsonic_getStarred_album_struct*)malloc((*getStarredStruct)->albumCount * sizeof(opensubsonic_getStarred_album_struct));
|
||||
(*getStarredStruct)->albums = malloc((*getStarredStruct)->albumCount * sizeof(opensubsonic_getStarred_album_struct));
|
||||
|
||||
for (int i = 0; i < (*getStarredStruct)->albumCount; i++) {
|
||||
(*getStarredStruct)->albums[i].id = NULL;
|
||||
@@ -160,7 +160,7 @@ int opensubsonic_getStarred_parse(char* data, opensubsonic_getStarred_struct** g
|
||||
if ((*getStarredStruct)->songCount != -1) {
|
||||
// Count, allocate, initialize, and extract
|
||||
(*getStarredStruct)->songCount = cJSON_GetArraySize(song_root);
|
||||
(*getStarredStruct)->songs = (opensubsonic_getStarred_song_struct*)malloc((*getStarredStruct)->songCount * sizeof(opensubsonic_getStarred_song_struct));
|
||||
(*getStarredStruct)->songs = malloc((*getStarredStruct)->songCount * sizeof(opensubsonic_getStarred_song_struct));
|
||||
|
||||
for (int i = 0; i < (*getStarredStruct)->songCount; i++) {
|
||||
(*getStarredStruct)->songs[i].id = NULL;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
// Returns 1 if failure occured, else 0
|
||||
int opensubsonic_ping_parse(char* data, opensubsonic_ping_struct** pingStruct) {
|
||||
// Allocate on the heap
|
||||
*pingStruct = (opensubsonic_ping_struct*)malloc(sizeof(opensubsonic_ping_struct));
|
||||
*pingStruct = malloc(sizeof(opensubsonic_ping_struct));
|
||||
|
||||
// Initialize struct variables
|
||||
(*pingStruct)->status = NULL;
|
||||
@@ -61,7 +61,6 @@ int opensubsonic_ping_parse(char* data, opensubsonic_ping_struct** pingStruct) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Free the dynamically allocated elements of the opensubsonic_ping_struct structure
|
||||
void opensubsonic_ping_struct_free(opensubsonic_ping_struct** pingStruct) {
|
||||
logger_log_general(__func__, "Freeing /ping endpoint heap objects.");
|
||||
if ((*pingStruct)->status != NULL) { free((*pingStruct)->status); }
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// Returns 1 if failure occured, else 0
|
||||
int opensubsonic_scrobble_parse(char* data, opensubsonic_scrobble_struct** scrobbleStruct) {
|
||||
// Allocate and initialize
|
||||
(*scrobbleStruct) = (opensubsonic_scrobble_struct*)malloc(sizeof(opensubsonic_scrobble_struct));
|
||||
(*scrobbleStruct) = malloc(sizeof(opensubsonic_scrobble_struct));
|
||||
(*scrobbleStruct)->status = NULL;
|
||||
(*scrobbleStruct)->errorCode = 0;
|
||||
(*scrobbleStruct)->errorMessage = NULL;
|
||||
|
||||
Reference in New Issue
Block a user