Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » PHP
  • » [PHP-DEV] Array_merge, safety and race condition? [RSS Feed]

#1 Nov. 11, 2005 17:29:37

Ezra N.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Array_merge, safety and race condition?


I sent this to the general list, but I didn't get definitive answer.
Maybe internals is the better forum to talk about it.
If you have a test code, or other pointers towards a definitive answer,
I'd love to try it.

Thanks




Php experts everywhere,

I want to merge two arrays, and I want to store the result as the first
array. Something like the following:


$array1 = array_merge ($array1, $array2);


So far the code gives me what I want. However, suppose if $array1 is
extremely huge, am I introducing a bug here because of possible race
condition? It's possible that array_merge has two write something to
$array1 (left hand side) before it even finishes reading it (argument)
in the first place. Let alone merging the two.

Should I just go conservative and do:

$tmp = array_merge($array1, $array2);
$array1 = $tmp;


Thank you,
Ezra

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

  • Root
  • » PHP
  • » [PHP-DEV] Array_merge, safety and race condition? [RSS Feed]

Board footer

Moderator control

Enjoy the 18th of November
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support