Re: pipeProcess output to hash string

2023-09-09 Thread evilrat via Digitalmars-d-learn
On Saturday, 9 September 2023 at 16:49:30 UTC, user1234 wrote: not sure why you append "/?" to the program name. Windows maybe? Try this. auto result = std.process.pipeProcess(["whoami", "/?"], redirect);

Re: pipeProcess output to hash string

2023-09-09 Thread user1234 via Digitalmars-d-learn
On Saturday, 9 September 2023 at 15:44:44 UTC, Vino wrote: Hi All, Request your help on how to convert the output of std.process.pipeProcess to hash string ``` auto test(in Redirect redirect=Redirect.stdout | Redirect.stderr) { import std.process; import std.digest.crc; import

pipeProcess output to hash string

2023-09-09 Thread Vino via Digitalmars-d-learn
Hi All, Request your help on how to convert the output of std.process.pipeProcess to hash string ``` auto test(in Redirect redirect=Redirect.stdout | Redirect.stderr) { import std.process; import std.digest.crc; import std.stdio: writeln; result = std.process.pipeProcess

Re: Hipreme's Tip of of the day #09 - Using D shared libraries with dub

2023-09-09 Thread Kyle Ingraham via Digitalmars-d-learn
On Monday, 4 September 2023 at 23:57:03 UTC, Hipreme wrote: Hello again! -- As of some requests in DConf, I'll post here some things related (or not) to dub recipes. Since there is so many ways to build D and dub is quite the main way, I'll try to show other uncommon ways to use it, this is m

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-09 Thread rempas via Digitalmars-d-learn
On Saturday, 9 September 2023 at 10:54:34 UTC, bachmeier wrote: Hate to be that guy, but I posted a link to a stackoverflow question with the exact error message you were getting, and the solution. And I told you I had experienced the same error and that question fixed it. No reason to not sa

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-09 Thread bachmeier via Digitalmars-d-learn
On Saturday, 9 September 2023 at 09:30:10 UTC, rempas wrote: Bingo! You and Brad found out! Hate to be that guy, but I posted a link to a stackoverflow question with the exact error message you were getting, and the solution. And I told you I had experienced the same error and that question

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-09 Thread rempas via Digitalmars-d-learn
On Saturday, 9 September 2023 at 09:56:59 UTC, H. S. Teoh wrote: libc doesn't know what you intended. All it knows is that you asked it for 20 bytes (even though you actually needed 40), then later on its internal structures are corrupted (because you thought you got 40 bytes; storing data past

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-09 Thread rempas via Digitalmars-d-learn
On Saturday, 9 September 2023 at 09:47:14 UTC, Steven Schveighoffer wrote: You are focusing on the wrong problem. You asked for size bytes, and malloc gave you size bytes. It doesn't "know" anything special. Then you proceeded at some point to write *past* the size bytes. What did you overwr

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-09 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Sep 09, 2023 at 09:21:32AM +, rempas via Digitalmars-d-learn wrote: > On Saturday, 9 September 2023 at 08:54:14 UTC, Brad Roberts wrote: > > I'm pretty sure this is your problem. You're allocating size bytes > > which is only going to work where sizeof(T) == 1. Changing to > > malloc(

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 9 September 2023 at 09:21:32 UTC, rempas wrote: Now, if only one could expect how and why "libc" knows that and doesn't just care to give me the memory I asked it for? Or it could be than D does something additional without telling us? Which can explain when this memory is only pr

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-09 Thread rempas via Digitalmars-d-learn
On Saturday, 9 September 2023 at 09:04:18 UTC, Steven Schveighoffer wrote: This is not ideal. Why? Because 99% of the time, a poster has come here with a problem they don't know how to solve, and have focused in on where they *think* the problem is. However, the problem isn't there. But us read

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-09 Thread rempas via Digitalmars-d-learn
On Saturday, 9 September 2023 at 08:54:14 UTC, Brad Roberts wrote: I'm pretty sure this is your problem. You're allocating size bytes which is only going to work where sizeof(T) == 1. Changing to malloc(size * sizeof(T)) is likely going to work better. Oh man That was it! I had forget a

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On Friday, 8 September 2023 at 07:59:37 UTC, rempas wrote: I do have the following struct: ... That's some minimal code that I do have just to showcase it. This is not ideal. Why? Because 99% of the time, a poster has come here with a problem they don't know how to solve, and have focused

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-09 Thread Brad Roberts via Digitalmars-d-learn
On 9/8/2023 12:59 AM, rempas via Digitalmars-d-learn wrote: u64 _cap = 0; // Total amount of elements (not bytes) we can this._ptr = cast(T*)malloc(size); I'm pretty sure this is your problem. You're allocating size bytes which is only going to work where sizeof(T) == 1. Changing to ma

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-09 Thread rempas via Digitalmars-d-learn
On Friday, 8 September 2023 at 19:48:33 UTC, Basile B. wrote: My idea was that if you dont have defined a copy constructor and if an instance is assigned to another, then that other instance share the same pointer, which can cause memory errors. To eliminate that risk and to detect where def

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-09 Thread rempas via Digitalmars-d-learn
On Friday, 8 September 2023 at 19:14:47 UTC, H. S. Teoh wrote: The error message looks to me like a corruption of the malloc heap. These kinds of bugs are very hard to trace, because they may go undetected and only show up in specific circumstances, so small perturbations of completely unrelate

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-09 Thread rempas via Digitalmars-d-learn
On Friday, 8 September 2023 at 19:14:47 UTC, H. S. Teoh wrote: My guess is that you have a double-free somewhere, or there's a buffer overrun. Or maybe some bad interaction with the GC, e.g. if you tried to free a pointer from the GC heap. (Note that this may not immediately show up; free() c