rbb 99/09/07 14:24:45
Modified: src/lib/apr/file_io/unix open.c readwrite.c
src/lib/apr/lib apr_pools.c
src/lib/apr/network_io/unix sockets.c
Log:
Allor ap_palloc to work without a pool. Basically, this just uses malloc.
This also sets us up to allow multiple allocation methods in the same program.
Also fix some minor bugs I found.
Revision Changes Path
1.7 +0 -3 apache-2.0/src/lib/apr/file_io/unix/open.c
Index: open.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/open.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- open.c 1999/09/07 13:38:26 1.6
+++ open.c 1999/09/07 21:24:37 1.7
@@ -250,9 +250,6 @@
ap_os_file_t *thefile)
{
int *dafile = thefile;
- if (cont == NULL) {
- return APR_ENOCONT;
- }
if ((*file) == NULL) {
(*file) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t));
(*file)->cntxt = cont;
1.5 +1 -0 apache-2.0/src/lib/apr/file_io/unix/readwrite.c
Index: readwrite.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/readwrite.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- readwrite.c 1999/09/07 12:36:23 1.4
+++ readwrite.c 1999/09/07 21:24:38 1.5
@@ -263,6 +263,7 @@
if (rv != 1) {
return errno;
}
+ i++;
}
return APR_SUCCESS;
}
1.5 +41 -19 apache-2.0/src/lib/apr/lib/apr_pools.c
Index: apr_pools.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/lib/apr_pools.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- apr_pools.c 1999/08/31 05:32:35 1.4
+++ apr_pools.c 1999/09/07 21:24:42 1.5
@@ -772,18 +772,33 @@
* Round up requested size to an even number of alignment units
* (core clicks)
*/
- ap_pool_t *a = c->pool;
- int nclicks = 1 + ((reqsize - 1) / CLICK_SZ);
- int size = nclicks * CLICK_SZ;
+ ap_pool_t *a;
+ int nclicks;
+ int size;
/* First, see if we have space in the block most recently
* allocated to this pool
*/
- union block_hdr *blok = a->last;
- char *first_avail = blok->h.first_avail;
+ union block_hdr *blok;
+ char *first_avail;
char *new_first_avail;
+ if (c == NULL) {
+ return malloc(reqsize);
+ }
+ a = c->pool;
+ nclicks = 1 + ((reqsize - 1) / CLICK_SZ);
+ size = nclicks * CLICK_SZ;
+
+ /* First, see if we have space in the block most recently
+ * allocated to this pool
+ */
+
+ blok = a->last;
+ first_avail = blok->h.first_avail;
+ new_first_avail;
+
if (reqsize <= 0) {
return NULL;
}
@@ -1066,28 +1081,35 @@
ap_status_t (*child_cleanup) (void *))
{
struct cleanup *c;
- c = (struct cleanup *) ap_palloc(p, sizeof(struct cleanup));
- c->data = data;
- c->plain_cleanup = plain_cleanup;
- c->child_cleanup = child_cleanup;
- c->next = p->pool->cleanups;
- p->pool->cleanups = c;
+
+ if (p != NULL) {
+ c = (struct cleanup *) ap_palloc(p, sizeof(struct cleanup));
+ c->data = data;
+ c->plain_cleanup = plain_cleanup;
+ c->child_cleanup = child_cleanup;
+ c->next = p->pool->cleanups;
+ p->pool->cleanups = c;
+ }
}
API_EXPORT(void) ap_kill_cleanup(struct context_t *p, void *data,
ap_status_t (*cleanup) (void *))
{
- struct cleanup *c = p->pool->cleanups;
- struct cleanup **lastp = &p->pool->cleanups;
+ struct cleanup *c;
+ struct cleanup **lastp;
+ if (p == NULL)
+ return;
+ c = p->pool->cleanups;
+ lastp = &p->pool->cleanups;
while (c) {
- if (c->data == data && c->plain_cleanup == cleanup) {
- *lastp = c->next;
- break;
- }
+ if (c->data == data && c->plain_cleanup == cleanup) {
+ *lastp = c->next;
+ break;
+ }
- lastp = &c->next;
- c = c->next;
+ lastp = &c->next;
+ c = c->next;
}
}
1.5 +1 -1 apache-2.0/src/lib/apr/network_io/unix/sockets.c
Index: sockets.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/unix/sockets.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- sockets.c 1999/09/04 00:21:16 1.4
+++ sockets.c 1999/09/07 21:24:44 1.5
@@ -364,7 +364,7 @@
if (sock == NULL) {
return APR_ENOSOCKET;
}
- thesock = &(sock->socketdes);
+ *thesock = sock->socketdes;
return APR_SUCCESS;
}
|