striker 01/07/04 16:28:54
Modified: memory/unix apr_sms_trivial.c
Log:
Fixed a stupid typo that caused the realloc to segfault.
Moved the realloc so we don't need a forward declaration.
Revision Changes Path
1.13 +30 -32 apr/memory/unix/apr_sms_trivial.c
Index: apr_sms_trivial.c
===================================================================
RCS file: /home/cvs/apr/memory/unix/apr_sms_trivial.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- apr_sms_trivial.c 2001/07/04 20:27:22 1.12
+++ apr_sms_trivial.c 2001/07/04 23:28:54 1.13
@@ -219,38 +219,6 @@
return mem;
}
-static apr_status_t apr_sms_trivial_free(apr_sms_t *sms, void *mem);
-
-static void *apr_sms_trivial_realloc(apr_sms_t *sms, void *mem, apr_size_t
reqsize)
-{
- void *new_mem;
- apr_size_t size;
- node_t *node;
- char *endp;
-
- reqsize = APR_ALIGN_DEFAULT(reqsize);
-
- new_mem = apr_sms_trivial_malloc(sms, reqsize);
-
- if (new_mem) {
- node = BLOCK_T((char *)mem - SIZEOF_NODE_T)->node;
-
- endp = node->first_avail;
- if (endp == (char *)node + SIZEOF_NODE_T)
- endp += node->avail_size;
-
- size = endp - (char *)mem;
- if (size > reqsize)
- size = reqsize;
-
- memcpy(new_mem, mem, size);
- }
-
- apr_sms_trivial_free(sms, mem);
-
- return new_mem;
-}
-
static apr_status_t apr_sms_trivial_free(apr_sms_t *sms, void *mem)
{
node_t *node, *sentinel;
@@ -299,6 +267,36 @@
apr_lock_release(SMS_TRIVIAL_T(sms)->lock);
return APR_SUCCESS;
+}
+
+static void *apr_sms_trivial_realloc(apr_sms_t *sms, void *mem, apr_size_t
reqsize)
+{
+ void *new_mem;
+ apr_size_t size;
+ node_t *node;
+ char *endp;
+
+ reqsize = APR_ALIGN_DEFAULT(reqsize);
+
+ new_mem = apr_sms_trivial_malloc(sms, reqsize);
+
+ if (new_mem) {
+ node = BLOCK_T((char *)mem - SIZEOF_BLOCK_T)->node;
+
+ endp = node->first_avail;
+ if (endp == (char *)node + SIZEOF_NODE_T)
+ endp += node->avail_size;
+
+ size = endp - (char *)mem;
+ if (size > reqsize)
+ size = reqsize;
+
+ memcpy(new_mem, mem, size);
+ }
+
+ apr_sms_trivial_free(sms, mem);
+
+ return new_mem;
}
static apr_status_t apr_sms_trivial_reset(apr_sms_t *sms)