Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:23207 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67372 invoked by uid 1010); 9 May 2006 04:58:48 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 67357 invoked from network); 9 May 2006 04:58:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 May 2006 04:58:48 -0000 X-PHP-List-Original-Sender: bfoz@bfoz.net X-Host-Fingerprint: 63.240.77.84 sccrmhc14.comcast.net NetCache Data OnTap 5.x Received: from ([63.240.77.84:51716] helo=sccrmhc14.comcast.net) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id F1/EC-63885-88120644 for ; Tue, 09 May 2006 00:58:48 -0400 Received: from [192.168.0.5] (c-24-6-134-233.hsd1.ca.comcast.net[24.6.134.233]) by comcast.net (sccrmhc14) with ESMTP id <2006050904584401400kftp5e>; Tue, 9 May 2006 04:58:44 +0000 Message-ID: <44602183.8010309@bfoz.net> Date: Mon, 08 May 2006 21:58:43 -0700 User-Agent: Thunderbird 1.5.0.2 (X11/20060507) MIME-Version: 1.0 To: internals X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: INIT_CLASS_ENTRY and char* From: bfoz@bfoz.net (Brandon Fosdick) I think I found a bug in the INIT_OVERLOADED_CLASS_ENTRY_EX macro. At least, I think its a bug, somebody else might think its a feature. :) If you do something like INIT_CLASS_ENTRY(ce, "MyClass", ...) everything works fine. However, if you have something like void register_class(char* name, ...) { ... INIT_CLASS_ENTRY(ce, name, ...); ... } things don't work so well. When I run this through gdb and break right after the macro, ce.name = "MyClass" as expected. But ce.name_length = 3, which is not quite right. It looks to me like the problem is in the 3rd line of the INIT_OVERLOADED_CLASS_ENTRY_EX macro... --- #define INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \ { \ class_container.name = strdup(class_name); \ class_container.name_length = sizeof(class_name) - 1; \ --- ...where sizeof() is used instead of strlen(). When class_name is a variable, sizeof() dutifully returns the size of the variable instead of the string length. Obviously this works, and provides a bit of a speed boost, when using literal strings, but it doesn't work so well for char*'s. Is this desired behavior or a bug?