MCPcopy Create free account
hub / github.com/HyperDbg/HyperDbg / NewTemp

Function NewTemp

hyperdbg/script-engine/code/common.c:654–684  ·  view source on GitHub ↗

* @brief Allocates a new temporary variable and returns it * * @param Error the error type pointer * @return PSCRIPT_ENGINE_TOKEN */

Source from the content-addressed store, hash-verified

652 * @return PSCRIPT_ENGINE_TOKEN
653 */
654PSCRIPT_ENGINE_TOKEN
655NewTemp(PSCRIPT_ENGINE_ERROR_TYPE Error)
656{
657 static unsigned int TempID = 0;
658 int i;
659 for (i = 0; i < MAX_TEMP_COUNT; i++)
660 {
661 if (CurrentUserDefinedFunction->TempMap[i] == 0)
662 {
663 TempID = i;
664 CurrentUserDefinedFunction->TempMap[i] = 1;
665 break;
666 }
667 }
668 if (i == MAX_TEMP_COUNT)
669 {
670 *Error = SCRIPT_ENGINE_ERROR_TEMP_LIST_FULL;
671 }
672 PSCRIPT_ENGINE_TOKEN Temp = NewUnknownToken();
673 char TempValue[8];
674 sprintf(TempValue, "%d", TempID);
675 strcpy(Temp->Value, TempValue);
676 Temp->Type = TEMP;
677
678 if (CurrentUserDefinedFunction->MaxTempNumber < (i + 1))
679 {
680 CurrentUserDefinedFunction->MaxTempNumber = i + 1;
681 }
682
683 return Temp;
684}
685
686/**
687 * @brief Frees the memory allocated by Temp

Callers 1

CodeGenFunction · 0.85

Calls 1

NewUnknownTokenFunction · 0.85

Tested by

no test coverage detected