Skip to content
Permalink
Browse files

Merge pull request #97 from morlad/less-memory-fragmentation

Remove unnecessary 4-byte-sized allocations
  • Loading branch information...
Turupawn committed Jun 18, 2019
2 parents 57bee3e + 13a3f9c commit 7c6d1d8a297e89031310d19404919b01ec2571bd
Showing with 101 additions and 152 deletions.
  1. +2 −2 src/c++/methods/AuthenticationInstanceMethods.cpp
  2. +3 −3 src/c++/methods/CommentsInstanceMethods.cpp
  3. +3 −3 src/c++/methods/DependenciesIntanceMethods.cpp
  4. +4 −4 src/c++/methods/ExternalAuthenticationInstanceMethods.cpp
  5. +1 −1 src/c++/methods/ImageInstanceMethods.cpp
  6. +7 −7 src/c++/methods/MeInstanceMethods.cpp
  7. +7 −7 src/c++/methods/MediaInstanceMethods.cpp
  8. +3 −3 src/c++/methods/MetadataKVPInstanceMethods.cpp
  9. +2 −2 src/c++/methods/ModEventInstanceMethods.cpp
  10. +5 −5 src/c++/methods/ModInstanceMethods.cpp
  11. +2 −2 src/c++/methods/ModStatsInstanceMethods.cpp
  12. +4 −4 src/c++/methods/ModfileInstanceMethods.cpp
  13. +1 −1 src/c++/methods/RatingsInstanceMethods.cpp
  14. +1 −1 src/c++/methods/ReportsInstanceMethods.cpp
  15. +2 −2 src/c++/methods/SubscribeInstanceMethods.cpp
  16. +3 −3 src/c++/methods/TagsInstanceMethods.cpp
  17. +2 −4 src/c++/methods/callbacks/AuthenticationInstanceCallbacks.cpp
  18. +3 −6 src/c++/methods/callbacks/CommentsInstanceCallbacks.cpp
  19. +3 −6 src/c++/methods/callbacks/DependenciesIntanceCallbaks.cpp
  20. +4 −8 src/c++/methods/callbacks/ExternalAuthenticationInstanceCallbacks.cpp
  21. +1 −2 src/c++/methods/callbacks/ImageInstanceCallbacks.cpp
  22. +7 −14 src/c++/methods/callbacks/MeInstanceCallbacks.cpp
  23. +7 −14 src/c++/methods/callbacks/MediaInstanceCallbacks.cpp
  24. +3 −6 src/c++/methods/callbacks/MetadataKVPInstanceCallbacks.cpp
  25. +2 −4 src/c++/methods/callbacks/ModEventsInstanceCallbacks.cpp
  26. +5 −10 src/c++/methods/callbacks/ModInstanceCallbacks.cpp
  27. +2 −4 src/c++/methods/callbacks/ModStatsInstanceCallbacks.cpp
  28. +5 −10 src/c++/methods/callbacks/ModfileInstanceCallbacks.cpp
  29. +1 −2 src/c++/methods/callbacks/RatingsInstanceCallbacks.cpp
  30. +1 −2 src/c++/methods/callbacks/ReportsInstanceCallbacks.cpp
  31. +2 −4 src/c++/methods/callbacks/SubscriptionInstanceCallbacks.cpp
  32. +3 −6 src/c++/methods/callbacks/TagsInstanceCallbacks.cpp
@@ -17,7 +17,7 @@ void Instance::emailRequest(const std::string &email, const std::function<void(c
struct GenericCall *email_request_call = new GenericCall{callback};
email_request_calls[current_call_id] = email_request_call;

modioEmailRequest(new u32(current_call_id), email.c_str(), &onEmailRequest);
modioEmailRequest((void*)((uintptr_t)current_call_id), email.c_str(), &onEmailRequest);

current_call_id++;
}
@@ -27,7 +27,7 @@ void Instance::emailExchange(const std::string &security_code, const std::functi
struct GenericCall *email_exchange_call = new GenericCall{callback};
email_exchange_calls[current_call_id] = email_exchange_call;

modioEmailExchange(new u32(current_call_id), security_code.c_str(), &onEmailExchange);
modioEmailExchange((void*)((uintptr_t)current_call_id), security_code.c_str(), &onEmailExchange);

current_call_id++;
}
@@ -7,7 +7,7 @@ void Instance::getAllModComments(u32 mod_id, modio::FilterCreator &filter, const
struct GetAllModCommentsCall *get_all_mod_comments_call = new GetAllModCommentsCall{callback};
get_all_mod_comments_calls[current_call_id] = get_all_mod_comments_call;

modioGetAllModComments(new u32(current_call_id), mod_id, *filter.getFilter(), &onGetAllModComments);
modioGetAllModComments((void*)((uintptr_t)current_call_id), mod_id, *filter.getFilter(), &onGetAllModComments);

current_call_id++;
}
@@ -17,7 +17,7 @@ void Instance::getModComment(u32 mod_id, u32 comment_id, const std::function<voi
struct GetModCommentCall *get_mod_comment_call = new GetModCommentCall{callback};
get_mod_comment_calls[current_call_id] = get_mod_comment_call;

modioGetModComment(new u32(current_call_id), mod_id, comment_id, &onGetModComment);
modioGetModComment((void*)((uintptr_t)current_call_id), mod_id, comment_id, &onGetModComment);

current_call_id++;
}
@@ -27,7 +27,7 @@ void Instance::deleteModComment(u32 mod_id, u32 comment_id, const std::function<
struct GenericCall *delete_mod_comment_call = new GenericCall{callback};
delete_mod_comment_calls[current_call_id] = delete_mod_comment_call;

modioDeleteModComment(new u32(current_call_id), mod_id, comment_id, &onDeleteModComment);
modioDeleteModComment((void*)((uintptr_t)current_call_id), mod_id, comment_id, &onDeleteModComment);

current_call_id++;
}
@@ -7,7 +7,7 @@ void Instance::getAllModDependencies(u32 mod_id, const std::function<void(const
struct GetAllModDependenciesCall *get_all_mod_dependencies_call = new GetAllModDependenciesCall{callback};
get_all_mod_dependencies_calls[current_call_id] = get_all_mod_dependencies_call;

modioGetAllModDependencies(new u32(current_call_id), mod_id, &onGetAllModDependencies);
modioGetAllModDependencies((void*)((uintptr_t)current_call_id), mod_id, &onGetAllModDependencies);

current_call_id++;
}
@@ -21,7 +21,7 @@ void Instance::addModDependencies(u32 mod_id, std::vector<u32> dependencies, con
struct GenericCall *add_mod_dependencies_call = new GenericCall{callback};
add_mod_dependencies_calls[current_call_id] = add_mod_dependencies_call;

modioAddModDependencies(new u32(current_call_id), mod_id, dependencies_array, (u32)dependencies.size(), &onAddModDependencies);
modioAddModDependencies((void*)((uintptr_t)current_call_id), mod_id, dependencies_array, (u32)dependencies.size(), &onAddModDependencies);

current_call_id++;

@@ -37,7 +37,7 @@ void Instance::deleteModDependencies(u32 mod_id, std::vector<u32> dependencies,
struct GenericCall *delete_mod_dependencies_call = new GenericCall{callback};
delete_mod_dependencies_calls[current_call_id] = delete_mod_dependencies_call;

modioDeleteModDependencies(new u32(current_call_id), mod_id, dependencies_array, (u32)dependencies.size(), &onDeleteModDependencies);
modioDeleteModDependencies((void*)((uintptr_t)current_call_id), mod_id, dependencies_array, (u32)dependencies.size(), &onDeleteModDependencies);

current_call_id++;

@@ -8,7 +8,7 @@ void Instance::galaxyAuth(const std::string &appdata, const std::function<void(c
struct GenericCall *galaxy_auth_call = new GenericCall{callback};
galaxy_auth_calls[current_call_id] = galaxy_auth_call;

modioGalaxyAuth(new u32(current_call_id), appdata.c_str(), &onGalaxyAuth);
modioGalaxyAuth((void*)((uintptr_t)current_call_id), appdata.c_str(), &onGalaxyAuth);

current_call_id++;
}
@@ -18,7 +18,7 @@ void Instance::steamAuth(const unsigned char* rgubTicket, u32 cubTicket, const s
struct GenericCall *steam_auth_call = new GenericCall{callback};
steam_auth_calls[current_call_id] = steam_auth_call;

modioSteamAuth(new u32(current_call_id), rgubTicket, cubTicket, &onSteamAuth);
modioSteamAuth((void*)((uintptr_t)current_call_id), rgubTicket, cubTicket, &onSteamAuth);

current_call_id++;
}
@@ -28,7 +28,7 @@ void Instance::steamAuthEncoded(const std::string &base64_ticket, const std::fun
struct GenericCall *steam_auth_encoded_call = new GenericCall{callback};
steam_auth_encoded_calls[current_call_id] = steam_auth_encoded_call;

modioSteamAuthEncoded(new u32(current_call_id), base64_ticket.c_str(), &onSteamAuthEncoded);
modioSteamAuthEncoded((void*)((uintptr_t)current_call_id), base64_ticket.c_str(), &onSteamAuthEncoded);

current_call_id++;
}
@@ -38,7 +38,7 @@ void Instance::linkExternalAccount(u32 service, const std::string &service_id, c
struct GenericCall *link_external_account_call = new GenericCall{callback};
link_external_account_calls[current_call_id] = link_external_account_call;

modioLinkExternalAccount(new u32(current_call_id), service, service_id.c_str(), email.c_str(), &onLinkExternalAccount);
modioLinkExternalAccount((void*)((uintptr_t)current_call_id), service, service_id.c_str(), email.c_str(), &onLinkExternalAccount);

current_call_id++;
}
@@ -7,7 +7,7 @@ void Instance::downloadImage(const std::string &image_url, const std::string &pa
struct GenericCall *download_image_call = new GenericCall{callback};
download_image_calls[current_call_id] = download_image_call;

modioDownloadImage(new u32(current_call_id), image_url.c_str(), path.c_str(), &onDownloadImage);
modioDownloadImage((void*)((uintptr_t)current_call_id), image_url.c_str(), path.c_str(), &onDownloadImage);

current_call_id++;
}
@@ -7,7 +7,7 @@ void Instance::getAuthenticatedUser(const std::function<void(const modio::Respon
struct GetAuthenticatedUserCall *get_authenticated_user_call = new GetAuthenticatedUserCall{callback};
get_authenticated_user_calls[current_call_id] = get_authenticated_user_call;

modioGetAuthenticatedUser(new u32(current_call_id), &onGetAuthenticatedUser);
modioGetAuthenticatedUser((void*)((uintptr_t)current_call_id), &onGetAuthenticatedUser);

current_call_id++;
}
@@ -17,7 +17,7 @@ void Instance::getUserSubscriptions(modio::FilterCreator &filter, const std::fun
struct GetUserSubscriptionsCall *get_user_subscriptions_call = new GetUserSubscriptionsCall{callback};
get_user_subscriptions_calls[current_call_id] = get_user_subscriptions_call;

modioGetUserSubscriptions(new u32(current_call_id), *filter.getFilter(), &onGetUserSubscriptions);
modioGetUserSubscriptions((void*)((uintptr_t)current_call_id), *filter.getFilter(), &onGetUserSubscriptions);

current_call_id++;
}
@@ -27,7 +27,7 @@ void Instance::getUserEvents(modio::FilterCreator &filter, const std::function<v
struct GetUserEventsCall *get_user_events_call = new GetUserEventsCall{callback};
get_user_events_calls[current_call_id] = get_user_events_call;

modioGetUserEvents(new u32(current_call_id), *filter.getFilter(), &onGetUserEvents);
modioGetUserEvents((void*)((uintptr_t)current_call_id), *filter.getFilter(), &onGetUserEvents);

current_call_id++;
}
@@ -37,7 +37,7 @@ void Instance::getUserGames(modio::FilterCreator &filter, const std::function<vo
struct GetUserGamesCall *get_user_games_call = new GetUserGamesCall{callback};
get_user_games_calls[current_call_id] = get_user_games_call;

modioGetUserGames(new u32(current_call_id), *filter.getFilter(), &onGetUserGames);
modioGetUserGames((void*)((uintptr_t)current_call_id), *filter.getFilter(), &onGetUserGames);

current_call_id++;
}
@@ -47,7 +47,7 @@ void Instance::getUserMods(modio::FilterCreator &filter, const std::function<voi
struct GetUserModsCall *get_user_mods_call = new GetUserModsCall{callback};
get_user_mods_calls[current_call_id] = get_user_mods_call;

modioGetUserMods(new u32(current_call_id), *filter.getFilter(), &onGetUserMods);
modioGetUserMods((void*)((uintptr_t)current_call_id), *filter.getFilter(), &onGetUserMods);

current_call_id++;
}
@@ -57,7 +57,7 @@ void Instance::getUserModfiles(modio::FilterCreator &filter, const std::function
struct GetUserModfilesCall *get_user_modfiles_call = new GetUserModfilesCall{callback};
get_user_modfiles_calls[current_call_id] = get_user_modfiles_call;

modioGetUserModfiles(new u32(current_call_id), *filter.getFilter(), &onGetUserModfiles);
modioGetUserModfiles((void*)((uintptr_t)current_call_id), *filter.getFilter(), &onGetUserModfiles);

current_call_id++;
}
@@ -67,7 +67,7 @@ void Instance::getUserRatings(modio::FilterCreator &filter, const std::function<
struct GetUserRatingsCall *get_user_ratings_call = new GetUserRatingsCall{callback};
get_user_ratings_calls[current_call_id] = get_user_ratings_call;

modioGetUserRatings(new u32(current_call_id), *filter.getFilter(), &onGetUserRatings);
modioGetUserRatings((void*)((uintptr_t)current_call_id), *filter.getFilter(), &onGetUserRatings);

current_call_id++;
}
@@ -7,7 +7,7 @@ void Instance::addModLogo(u32 mod_id, std::string logo_path, const std::function
struct GenericCall *add_mod_logo_call = new GenericCall{callback};
add_mod_logo_calls[current_call_id] = add_mod_logo_call;

modioAddModLogo(new u32(current_call_id), mod_id, logo_path.c_str(), &onAddModLogo);
modioAddModLogo((void*)((uintptr_t)current_call_id), mod_id, logo_path.c_str(), &onAddModLogo);

current_call_id++;
}
@@ -24,7 +24,7 @@ void Instance::addModImages(u32 mod_id, std::vector<std::string> image_paths, co
struct GenericCall *add_mod_images_call = new GenericCall{callback};
add_mod_images_calls[current_call_id] = add_mod_images_call;

modioAddModImages(new u32(current_call_id), mod_id, image_paths_array, (u32)image_paths.size(), &onAddModImages);
modioAddModImages((void*)((uintptr_t)current_call_id), mod_id, image_paths_array, (u32)image_paths.size(), &onAddModImages);

current_call_id++;

@@ -45,7 +45,7 @@ void Instance::addModYoutubeLinks(u32 mod_id, std::vector<std::string> youtube_l
struct GenericCall *add_mod_youtube_links_call = new GenericCall{callback};
add_mod_youtube_links_calls[current_call_id] = add_mod_youtube_links_call;

modioAddModYoutubeLinks(new u32(current_call_id), mod_id, youtube_links_array, (u32)youtube_links.size(), &onAddModYoutubeLinks);
modioAddModYoutubeLinks((void*)((uintptr_t)current_call_id), mod_id, youtube_links_array, (u32)youtube_links.size(), &onAddModYoutubeLinks);

current_call_id++;

@@ -66,7 +66,7 @@ void Instance::addModSketchfabLinks(u32 mod_id, std::vector<std::string> sketchf
struct GenericCall *add_mod_sketchfab_links_call = new GenericCall{callback};
add_mod_sketchfab_links_calls[current_call_id] = add_mod_sketchfab_links_call;

modioAddModSketchfabLinks(new u32(current_call_id), mod_id, sketchfab_links_array, (u32)sketchfab_links.size(), &onAddModSketchfabLinks);
modioAddModSketchfabLinks((void*)((uintptr_t)current_call_id), mod_id, sketchfab_links_array, (u32)sketchfab_links.size(), &onAddModSketchfabLinks);

for (size_t i = 0; i < sketchfab_links.size(); i++)
delete[] sketchfab_links_array[i];
@@ -87,7 +87,7 @@ void Instance::deleteModImages(u32 mod_id, std::vector<std::string> image_paths,
struct GenericCall *delete_mod_images_call = new GenericCall{callback};
delete_mod_images_calls[current_call_id] = delete_mod_images_call;

modioDeleteModImages(new u32(current_call_id), mod_id, image_paths_array, (u32)image_paths.size(), &onDeleteModImages);
modioDeleteModImages((void*)((uintptr_t)current_call_id), mod_id, image_paths_array, (u32)image_paths.size(), &onDeleteModImages);

current_call_id++;

@@ -108,7 +108,7 @@ void Instance::deleteModYoutubeLinks(u32 mod_id, std::vector<std::string> youtub
struct GenericCall *delete_mod_youtube_links_call = new GenericCall{callback};
delete_mod_youtube_links_calls[current_call_id] = delete_mod_youtube_links_call;

modioDeleteModYoutubeLinks(new u32(current_call_id), mod_id, youtube_links_array, (u32)youtube_links.size(), &onDeleteModYoutubeLinks);
modioDeleteModYoutubeLinks((void*)((uintptr_t)current_call_id), mod_id, youtube_links_array, (u32)youtube_links.size(), &onDeleteModYoutubeLinks);

current_call_id++;

@@ -129,7 +129,7 @@ void Instance::deleteModSketchfabLinks(u32 mod_id, std::vector<std::string> sket
struct GenericCall *delete_mod_sketchfab_links_call = new GenericCall{callback};
delete_mod_sketchfab_links_calls[current_call_id] = delete_mod_sketchfab_links_call;

modioDeleteModSketchfabLinks(new u32(current_call_id), mod_id, sketchfab_links_array, (u32)sketchfab_links.size(), &onDeleteModSketchfabLinks);
modioDeleteModSketchfabLinks((void*)((uintptr_t)current_call_id), mod_id, sketchfab_links_array, (u32)sketchfab_links.size(), &onDeleteModSketchfabLinks);

current_call_id++;

@@ -7,7 +7,7 @@ namespace modio
struct GetAllMetadataKVPCall* get_all_metadata_kvp_call = new GetAllMetadataKVPCall{callback};
get_all_metadata_kvp_calls[current_call_id] = get_all_metadata_kvp_call;

modioGetAllMetadataKVP(new u32(current_call_id), mod_id, &onGetAllMetadataKVP);
modioGetAllMetadataKVP((void*)((uintptr_t)current_call_id), mod_id, &onGetAllMetadataKVP);

current_call_id++;
}
@@ -27,7 +27,7 @@ namespace modio
struct GenericCall* add_metadata_kvp_call = new GenericCall{callback};
add_metadata_kvp_calls[current_call_id] = add_metadata_kvp_call;

modioAddMetadataKVP(new u32(current_call_id), mod_id, metadata_kvp_array, (u32)metadata_kvp.size(), &onAddMetadataKVP);
modioAddMetadataKVP((void*)((uintptr_t)current_call_id), mod_id, metadata_kvp_array, (u32)metadata_kvp.size(), &onAddMetadataKVP);

current_call_id++;

@@ -51,7 +51,7 @@ namespace modio
struct GenericCall* delete_metadata_kvp_call = new GenericCall{callback};
delete_metadata_kvp_calls[current_call_id] = delete_metadata_kvp_call;

modioDeleteMetadataKVP(new u32(current_call_id), mod_id, metadata_kvp_array, (u32)metadata_kvp.size(), &onDeleteMetadataKVP);
modioDeleteMetadataKVP((void*)((uintptr_t)current_call_id), mod_id, metadata_kvp_array, (u32)metadata_kvp.size(), &onDeleteMetadataKVP);

current_call_id++;

@@ -7,7 +7,7 @@ void Instance::getEvents(u32 mod_id, modio::FilterCreator &filter, const std::fu
struct GetEventsCall *get_events_call = new GetEventsCall{callback};
get_events_calls[current_call_id] = get_events_call;

modioGetEvents(new u32(current_call_id), mod_id, *filter.getFilter(), &onGetEvents);
modioGetEvents((void*)((uintptr_t)current_call_id), mod_id, *filter.getFilter(), &onGetEvents);

current_call_id++;
}
@@ -17,7 +17,7 @@ void Instance::getAllEvents(modio::FilterCreator &filter, const std::function<vo
struct GetAllEventsCall *get_all_events_call = new GetAllEventsCall{callback};
get_all_events_calls[current_call_id] = get_all_events_call;

modioGetAllEvents(new u32(current_call_id), *filter.getFilter(), &onGetAllEvents);
modioGetAllEvents((void*)((uintptr_t)current_call_id), *filter.getFilter(), &onGetAllEvents);

current_call_id++;
}
@@ -7,7 +7,7 @@ void Instance::getMod(u32 mod_id, const std::function<void(const modio::Response
struct GetModCall *get_mod_call = new GetModCall{callback};
get_mod_calls[current_call_id] = get_mod_call;

modioGetMod(new u32(current_call_id), mod_id, &onGetMod);
modioGetMod((void*)((uintptr_t)current_call_id), mod_id, &onGetMod);

current_call_id++;
}
@@ -17,7 +17,7 @@ void Instance::getAllMods(modio::FilterCreator &filter, const std::function<void
struct GetAllModsCall *get_mods_call = new GetAllModsCall{callback};
get_all_mods_calls[current_call_id] = get_mods_call;

modioGetAllMods(new u32(current_call_id), *filter.getFilter(), &onGetAllMods);
modioGetAllMods((void*)((uintptr_t)current_call_id), *filter.getFilter(), &onGetAllMods);

current_call_id++;
}
@@ -27,7 +27,7 @@ void Instance::addMod(modio::ModCreator &mod_handler, const std::function<void(c
struct AddModCall *add_mod_call = new AddModCall{callback};
add_mod_calls[current_call_id] = add_mod_call;

modioAddMod(new u32(current_call_id), *mod_handler.getModioModCreator(), &onAddMod);
modioAddMod((void*)((uintptr_t)current_call_id), *mod_handler.getModioModCreator(), &onAddMod);

current_call_id++;
}
@@ -37,7 +37,7 @@ void Instance::editMod(u32 mod_id, modio::ModEditor &mod_handler, const std::fun
struct EditModCall *edit_mod_call = new EditModCall{callback};
edit_mod_calls[current_call_id] = edit_mod_call;

modioEditMod(new u32(current_call_id), mod_id, *mod_handler.getModioModEditor(), &onEditMod);
modioEditMod((void*)((uintptr_t)current_call_id), mod_id, *mod_handler.getModioModEditor(), &onEditMod);

current_call_id++;
}
@@ -47,7 +47,7 @@ void Instance::deleteMod(u32 mod_id, const std::function<void(const modio::Respo
struct GenericCall *delete_mod_call = new GenericCall{callback};
delete_mod_calls[current_call_id] = delete_mod_call;

modioDeleteMod(new u32(current_call_id), mod_id, &onDeleteMod);
modioDeleteMod((void*)((uintptr_t)current_call_id), mod_id, &onDeleteMod);

current_call_id++;
}
@@ -7,7 +7,7 @@ void Instance::getModStats(u32 mod_id, const std::function<void(const modio::Res
struct GetModStatsCall *get_mod_stats_call = new GetModStatsCall{callback};
get_mod_stats_calls[current_call_id] = get_mod_stats_call;

modioGetModStats(new u32(current_call_id), mod_id, &onGetModStats);
modioGetModStats((void*)((uintptr_t)current_call_id), mod_id, &onGetModStats);

current_call_id++;
}
@@ -17,7 +17,7 @@ void Instance::getAllModStats(modio::FilterCreator &filter, const std::function<
struct GetAllModStatsCall *get_all_mod_stats_call = new GetAllModStatsCall{callback};
get_all_mod_stats_calls[current_call_id] = get_all_mod_stats_call;

modioGetAllModStats(new u32(current_call_id), *filter.getFilter(), &onGetAllModStats);
modioGetAllModStats((void*)((uintptr_t)current_call_id), *filter.getFilter(), &onGetAllModStats);

current_call_id++;
}

0 comments on commit 7c6d1d8

Please sign in to comment.
You can’t perform that action at this time.