Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:3052 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15755 invoked from network); 30 Jun 2003 16:51:32 -0000 Received: from unknown (HELO jedi.webgate.bg) (212.50.2.189) by pb1.pair.com with SMTP; 30 Jun 2003 16:51:32 -0000 Received: from andreywin (nik.office.webgate.bg [192.168.1.22]) by jedi.webgate.bg (8.12.9/8.9.3) with SMTP id h5UGuCPA015342; Mon, 30 Jun 2003 19:56:12 +0300 Message-ID: <000b01c33f27$ef318420$1601a8c0@andreywin> To: "Oriol" Cc: References: <20030630161359.78327.qmail@pb1.pair.com> Date: Mon, 30 Jun 2003 19:52:04 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1251" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Subject: Re: [PHP-DEV] Simple question From: andrey@webgate.bg ("Andrey Hristov") Oriol, try valgrind (aka memory checker) and you will hopefully find where your problem resides Andrey ----- Original Message ----- From: "Oriol" To: Sent: Monday, June 30, 2003 7:13 PM Subject: [PHP-DEV] Simple question > > Hello! I'm trying to write a trim function which expects a zval* of type > string, as follows: > > int zstrtrim(zval *z) > { > char *ptr1 = Z_STRVAL_P(z), *ptr2; > if (Z_STRLEN_P(z) == 0) return; > ptr2 = &ptr1[Z_STRLEN_P(z)-1]; > while (*ptr1 != 0) > { > if (*ptr1 > ' ') break; > ptr1++; > } > while (ptr2 > ptr1) > { > if (*ptr2 > ' ') break; > ptr2--; > } > ZVAL_STRINGL(z, ptr1, ptr2 - ptr1 + 1, 1); > } > > However, the last line gives me a segmentation fault. Why? How can I > change the value of the input zval string? > Thank you for your patience! > > Oriol > > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >