Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:23212 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61687 invoked by uid 1010); 9 May 2006 07:20:57 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 61665 invoked from network); 9 May 2006 07:20:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 May 2006 07:20:57 -0000 X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 81.169.182.136 ajaxatwork.net Linux 2.4/2.6 Received: from ([81.169.182.136:34033] helo=strato.aixcept.de) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id DD/D4-63885-EEC30644 for ; Tue, 09 May 2006 02:55:42 -0400 Received: from baumbart.mbo (dslb-084-063-047-027.pools.arcor-ip.net [84.63.47.27]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by strato.aixcept.de (Postfix) with ESMTP id 9EEC335C1C1; Tue, 9 May 2006 08:55:39 +0200 (CEST) Date: Tue, 9 May 2006 08:55:42 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <614987512.20060509085542@marcus-boerger.de> To: Brandon Fosdick Cc: internals In-Reply-To: <44602183.8010309@bfoz.net> References: <44602183.8010309@bfoz.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] INIT_CLASS_ENTRY and char* From: helly@php.net (Marcus Boerger) Hello Brandon, that's by design. Look into: ext/spl/spl_functions.c:spl_register_sub_class() regards marcus Tuesday, May 9, 2006, 6:58:43 AM, you wrote: > 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? Best regards, Marcus