im trying to understand how this implementation of the stack works, and i have come across this code
while(x-- >= 0){
token_size = (strlen(argv[x])+1)*sizeof(char);
*esp = *esp - token_size;
arr[x] = (uint32_t *)*esp;
memcpy(*esp, argv[x], strlen(argv[x])+1);
}
first of all, why do we decrement the stack pointer when we push arguments to the stack, i was under the impression that we add to the end of the stack and take from the front of the stack, so surely we would increment the stack pointer to add to the end of the stack? Please correct me if i am wrong ( which is almost definitely the case ).
back on the topic of the title, in the first part of the while loop the size of string argv[x] has +1 added to it, i am unsure why this is the case, and is this multiplying the string size by sizeof(char)
or is this a pointer?
any explanation ( little or large ) is appreciated, thankyou in advance!