Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: [Win32] pthreads and memory allocation

by BrowserUk (Patriarch)
on Nov 22, 2011 at 07:31 UTC ( [id://939384]=note: print w/replies, xml ) Need Help??


in reply to Re^2: [Win32] pthreads and memory allocation
in thread [Win32] pthreads and memory allocation

Another thought. If you add #undef malloc just prior to your use of malloc, you may find that the code will run without immediately crashing. But I make no claim that you won't run into similar problems later on.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: [Win32] pthreads and memory allocation
by syphilis (Archbishop) on Nov 22, 2011 at 08:38 UTC
    add #undef malloc just prior to your use of malloc

    Ooow .... I like *that* idea :-)
    I've actually placed the '#undef malloc' at the very start of the C code in that script, and the script now runs fine.

    Beyond that, nothing has yet been established. Now it's just a matter of seeing whether the same approach can help with PDL (which is where the actual problem that prompted this thread lies.)

    Cheers,
    Rob
      Ooow .... I like *that* idea :-) I've actually placed the '#undef malloc' at the very start of the C code in that script, and the script now runs fine.

      I've had some success with doing that to avoid PerlAPI interfering in stuff that is none of its business.

      But be careful. You can find yourself in the 'multiple C runtimes' trap passing pointers allocated by one to another to be freed with various possibilities of outcome.

      BTW. You should also be very wary of passing pointers to memory allocated on the stack of one thread as the thread argument to another. I realise it was only demo code, but it's worth a heads up.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://939384]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (10)
As of 2024-04-18 15:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found