Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:3681 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81249 invoked from network); 1 Aug 2003 15:46:46 -0000 Received: from unknown (HELO adsl-209-204-144-251.sonic.net) (209.204.144.251) by pb1.pair.com with SMTP; 1 Aug 2003 15:46:46 -0000 Received: from [127.0.0.1] (helo=192.168.1.2) by adsl-209-204-144-251.sonic.net with smtp (Exim 4.20) id 19ic7B-0008Rr-FB; Fri, 01 Aug 2003 08:46:45 -0700 Received: from 192.168.1.101 (SquirrelMail authenticated user mark) by 192.168.1.2 with HTTP; Fri, 1 Aug 2003 08:46:45 -0700 (PDT) Message-ID: <1253.192.168.1.101.1059752805.squirrel@192.168.1.2> In-Reply-To: References: Date: Fri, 1 Aug 2003 08:46:45 -0700 (PDT) To: "Ken Spencer" Cc: internals@lists.php.net Reply-To: mes@zeroc.com User-Agent: SquirrelMail/1.4.0-1 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 X-Priority: 3 Importance: Normal Subject: Re: [PHP-DEV] Making a variable global question From: mes@zeroc.com ("Mark Spruiell") Hi Ken, I'm fairly new to PHP extension programming, so forgive me if I'm missing the obvious, but your code appears to be trying to copy a global variable to a local scope. Is that your intent? If so, why can't the script do this itself by using a "global" declaration for the variable? For example: As for why you're getting a segfault, I suspect it's a reference counting issue. Have a look at the definition of ZEND_SET_SYMBOL_WITH_LENGTH in zend_API.h and you'll see it is modifying the container you retrieved from EG(symbol_table). Good luck, - Mark > I am trying to make a function for my extension that makes a predefined > variable global > > I have tried something along the lines of: > > if(zend_hash_find(&EG(symbol_table), var, strlen(var)+1, (void **) > &vars_data)!=FAILURE) > { > ZEND_SET_SYMBOL(EG(active_symbol_table), var, *vars_data); > } > > but it seg faults upon second execution. > > Can someone reccomend a more successful method of accomplishing this? > > > Chhers, > > Ken > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >