Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:3051 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78343 invoked by uid 1007); 30 Jun 2003 16:13:59 -0000 Message-ID: <20030630161359.78327.qmail@pb1.pair.com> To: internals@lists.php.net Date: Mon, 30 Jun 2003 18:13:04 +0200 Lines: 31 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Posted-By: 80.37.125.102 Subject: Simple question From: omagrane@anthill.es ("Oriol") 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