Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

Questions tagged [memory-pointer]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
52 views

Creating a local memory copy of a global uint256

I'm struggling to find any documentation that describes how to create a local memory copy of a global uint256 variable. Consider the following example: contract MyContract { uint256 myInt = 0; ...
jambolina's user avatar
0 votes
1 answer
48 views

Changing storage ref to storage pointer

In the function registerUser below, I am trying to access a global array of structs, and seeing if the argument I have passed exists in the global array or not. The code is as follows: user_details[] ...
Dhairya Khale's user avatar
2 votes
0 answers
581 views

Copying strings and bytes from memory to storage via storage references

What's the proper way to copy a string (or bytes) from memory to storage? When copied directly into a state variable lvalue (or into a mapping), there's no problem, but when assigning a string memory ...
Duncan Townsend's user avatar
1 vote
1 answer
60 views

When to use memory and when not to use?

I watched this video and he uses memory a lot like function verify(address _signer, string memory _message, bytes memory _sig. Why so? Could the function work without using memory? While the usual ...
ratib90486's user avatar
1 vote
1 answer
850 views

Understanding why this blob of assembly code adds 0x20 and 0x1f [duplicate]

The execute function defined in MakerDAO's DSProxy contains this blob of assembly code: assembly { let succeeded := delegatecall(sub(gas, 5000), _target, add(_data, 0x20), mload(_data), 0, 0) ...
Paul Razvan Berg's user avatar
4 votes
1 answer
2k views

In solidity, how to copy a string or pass it by value?

In this example I only modify string a, but both a and b are changed. It seems like the string wasn't copied. I only want to change a. How do you copy a string and how do you pass a string by value to ...
Skellomag's user avatar
2 votes
0 answers
184 views

Performing a C-like pointer increment in Solidity

I have a memory or calldata struct with an attribute of type byte[]. I want to have a memory variable with that data, except for the first n Bytes. In C, you'd just write typename variablename = ...
UTF-8's user avatar
  • 518
4 votes
2 answers
2k views

Declaring a memory array of storage pointers in Solidity

I would like to declare a variable as a memory array of pointers to storage arrays of uint256. For example: pragma solidity ^0.4.24; contract A { uint256[] public array0; uint256[] public ...
Jesbus's user avatar
  • 10.5k
5 votes
2 answers
2k views

Local storage variable

I am reading the solidity docs here and I seem to be struggling to understand the following. Data locations are important because they change how assignments behave: assignments between ...
Bobo's user avatar
  • 244