Simple question

From: Date: Mon, 30 Jun 2003 16:13:04 +0000
Subject: Simple question
Groups: php.internals 
Request: Send a blank email to internals+get-3051@lists.php.net to get a copy of this message
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

« previous php.internals (#3051) next »