Raised This Month: $ Target: $400
 0% 

Solved [ H3LP ] Can't return string on functions?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 06-23-2017 , 12:03   Re: [ H3LP ] Can't return string on functions?
Reply With Quote #1

Quote:
Originally Posted by KliPPy View Post
To me it looks like it still copies 1 time (out of the called function)
Yes if it is a plugin function, but fmt writes directly to this array.
Quote:
Originally Posted by KliPPy View Post
When assigning it copies 2 times.
Yes, we need to introduce an optimization for this.

GetPlayerName without copying:
Code:
#include <amxmodx> #if !defined MAX_NAME const MAX_NAME = 32; #endif const MaxNameLength = MAX_NAME - 1; public client_connect(player) {     server_print("%s connecting", GetPlayerName(player)); } native get_user_name2(a, b, c) = get_user_name; GetPlayerName(player) {     static returnStringAddr; #emit LOAD.S.PRI 0x10 #emit STOR.PRI returnStringAddr         get_user_name2(player, returnStringAddr, MaxNameLength); #emit RETN         new name[MaxNameLength + 1];     return name; }
__________________

Last edited by PRoSToTeM@; 06-23-2017 at 12:27.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:09.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode