digitalmars.D - How does one reset the pointer to the begining of _argptr
- Tyro (26/26) Dec 21 2004 I have the following:
- Simon Buchan (15/41) Dec 21 2004 whats wrong with argptr = _argptr again?
- Tyro (6/41) Dec 21 2004 With every incrementation, I have modified argptr.
- Simon Buchan (20/31) Dec 21 2004 Hmm, I don't get it... how can you assign values to a void*, then
- Georg Wrede (7/48) Dec 22 2004 This really looks like using a wrench where
I have the following: void foo(...) { void* argptr = _argptr; foreach(TypeInfo ti; _arguments) { if(ti == typeid(char[])) { /* do something */ argptr += (char[]).sizeof;} else if(ti == typeid(sometype)) { /* do something else */ argptr += (sometype).sizeof;} } /+ At this point the pointer should be pointing just beyond the last argument. My question question is how do I get it back to where it was when I initially entered this function? I have tried decrementing the pointer with: foreach(TypeInfo ti; _arguments) if(ti == typeid(sometype)) argptr -= sometype.sizeof; but that doesn't help at all. +/ } thanks for your assistance. Andrew
Dec 21 2004
On Tue, 21 Dec 2004 06:24:54 -0500, Tyro <ridimz_at yahoo.dot.com> wrote:I have the following: void foo(...) { void* argptr = _argptr; foreach(TypeInfo ti; _arguments) { if(ti == typeid(char[])) { /* do something */ argptr += (char[]).sizeof;} else if(ti == typeid(sometype)) { /* do something else */ argptr += (sometype).sizeof;} } /+ At this point the pointer should be pointing just beyond the last argument. My question question is how do I get it back to where it was when I initially entered this function? I have tried decrementing the pointer with: foreach(TypeInfo ti; _arguments) if(ti == typeid(sometype)) argptr -= sometype.sizeof; but that doesn't help at all. +/ } thanks for your assistance. Andrewwhats wrong with argptr = _argptr again? -- "Unhappy Microsoft customers have a funny way of becoming Linux, Salesforce.com and Oracle customers." - www.microsoft-watch.com: "The Year in Review: Microsoft Opens Up" -- "I plan on at least one critical patch every month, and I haven't been disappointed." - Adam Hansen, manager of security at Sonnenschein Nath & Rosenthal LLP (Quote from http://www.eweek.com/article2/0,1759,1736104,00.asp) -- "It's been a challenge to "reteach or retrain" Web users to pay for content, said Pizey" -Wired website: "The Incredible Shrinking Comic"
Dec 21 2004
Simon Buchan wrote:On Tue, 21 Dec 2004 06:24:54 -0500, Tyro <ridimz_at yahoo.dot.com> wrote:With every incrementation, I have modified argptr. Therefore, simply assigning it the values of _argptr will destroy the new values I've just assigned it. I want to get back to the beginning of argptr which now contains the new values I inserted.I have the following: void foo(...) { void* argptr = _argptr; foreach(TypeInfo ti; _arguments) { if(ti == typeid(char[])) { /* do something */ argptr += (char[]).sizeof;} else if(ti == typeid(sometype)) { /* do something else */ argptr += (sometype).sizeof;} } /+ At this point the pointer should be pointing just beyond the last argument. My question question is how do I get it back to where it was when I initially entered this function? I have tried decrementing the pointer with: foreach(TypeInfo ti; _arguments) if(ti == typeid(sometype)) argptr -= sometype.sizeof; but that doesn't help at all. +/ } thanks for your assistance. Andrewwhats wrong with argptr = _argptr again?
Dec 21 2004
On Tue, 21 Dec 2004 06:46:04 -0500, Tyro <ridimz_at yahoo.dot.com> wrote:Simon Buchan wrote:<snip>On Tue, 21 Dec 2004 06:24:54 -0500, Tyro <ridimz_at yahoo.dot.com> wrote:Hmm, I don't get it... how can you assign values to a void*, then want to move it back to the start? The ONLY information a void* holds is its location, by definition. Is what you want to create a new void* with the values of the args memcpy'ed after it? -- "Unhappy Microsoft customers have a funny way of becoming Linux, Salesforce.com and Oracle customers." - www.microsoft-watch.com: "The Year in Review: Microsoft Opens Up" -- "I plan on at least one critical patch every month, and I haven't been disappointed." - Adam Hansen, manager of security at Sonnenschein Nath & Rosenthal LLP (Quote from http://www.eweek.com/article2/0,1759,1736104,00.asp) -- "It's been a challenge to "reteach or retrain" Web users to pay for content, said Pizey" -Wired website: "The Incredible Shrinking Comic"whats wrong with argptr = _argptr again?With every incrementation, I have modified argptr. Therefore, simply assigning it the values of _argptr will destroy the new values I've just assigned it. I want to get back to the beginning of argptr which now contains the new values I inserted.
Dec 21 2004
In article <cq92dt$2noi$1 digitaldaemon.com>, Tyro says...Simon Buchan wrote:This really looks like using a wrench where a hammer should be used. (Or the other way 'round.) Instead of answering your question, maybe we should try to find out _what_ and _why_ you are trying to do? For example, if you want to change the strings, why don't you copy them into another array?On Tue, 21 Dec 2004 06:24:54 -0500, Tyro <ridimz_at yahoo.dot.com> wrote:With every incrementation, I have modified argptr. Therefore, simply assigning it the values of _argptr will destroy the new values I've just assigned it. I want to get back to the beginning of argptr which now contains the new values I inserted.I have the following: void foo(...) { void* argptr = _argptr; foreach(TypeInfo ti; _arguments) { if(ti == typeid(char[])) { /* do something */ argptr += (char[]).sizeof;} else if(ti == typeid(sometype)) { /* do something else */ argptr += (sometype).sizeof;} } /+ At this point the pointer should be pointing just beyond the last argument. My question question is how do I get it back to where it was when I initially entered this function? I have tried decrementing the pointer with: foreach(TypeInfo ti; _arguments) if(ti == typeid(sometype)) argptr -= sometype.sizeof; but that doesn't help at all. +/ } thanks for your assistance. Andrewwhats wrong with argptr = _argptr again?
Dec 22 2004