summaryrefslogtreecommitdiff
path: root/ext/shmop
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2004-11-05 00:05:55 +0000
committerIlia Alshanetsky <iliaa@php.net>2004-11-05 00:05:55 +0000
commit92a641e5e77ba9e97e7dcb6ec7e7484f7ddab1c5 (patch)
tree6141c7c6ba90f576a29597550effd54ec43a0fd0 /ext/shmop
parent4b76d82fe3f81970178a131e3f2119bbffbeada2 (diff)
downloadphp-git-92a641e5e77ba9e97e7dcb6ec7e7484f7ddab1c5.tar.gz
Simplify and cleanup code.
Diffstat (limited to 'ext/shmop')
-rw-r--r--ext/shmop/shmop.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/ext/shmop/shmop.c b/ext/shmop/shmop.c
index 78d9e1b973..6fe70f30b4 100644
--- a/ext/shmop/shmop.c
+++ b/ext/shmop/shmop.c
@@ -164,34 +164,33 @@ PHP_FUNCTION(shmop_open)
break;
default:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid access mode");
- efree(shmop);
- RETURN_FALSE;
+ goto err;
}
shmop->shmid = shmget(shmop->key, shmop->size, shmop->shmflg);
if (shmop->shmid == -1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to attach or create shared memory segment");
- efree(shmop);
- RETURN_FALSE;
+ goto err;
}
if (shmctl(shmop->shmid, IPC_STAT, &shm)) {
- efree(shmop);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to get shared memory segment information");
- RETURN_FALSE;
+ goto err;
}
shmop->addr = shmat(shmop->shmid, 0, shmop->shmatflg);
if (shmop->addr == (char*) -1) {
- efree(shmop);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to attach to shared memory segment");
- RETURN_FALSE;
+ goto err;
}
shmop->size = shm.shm_segsz;
rsid = zend_list_insert(shmop, shm_type);
RETURN_LONG(rsid);
+err:
+ efree(shmop);
+ RETURN_FALSE;
}
/* }}} */
@@ -222,12 +221,7 @@ PHP_FUNCTION(shmop_read)
RETURN_FALSE;
}
- if (start + count > shmop->size) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "count is out of range");
- RETURN_FALSE;
- }
-
- if (count < 0 ){
+ if (start + count > shmop->size || count < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "count is out of range");
RETURN_FALSE;
}