You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by sf...@apache.org on 2012/05/28 15:34:46 UTC
svn commit: r1343250 - in /apr/apr/branches/1.5.x: ./
include/apr_allocator.h include/apr_pools.h include/apr_strings.h
Author: sf
Date: Mon May 28 13:34:45 2012
New Revision: 1343250
URL: http://svn.apache.org/viewvc?rev=1343250&view=rev
Log:
Merge r1103310, r1341193:
Add some nonnull and pure attributes
add attribute alloc_size to a few functions
This allows gcc's -D_FORTIFY_SOURCE=2 to do some overflow checks
Modified:
apr/apr/branches/1.5.x/ (props changed)
apr/apr/branches/1.5.x/include/apr_allocator.h
apr/apr/branches/1.5.x/include/apr_pools.h
apr/apr/branches/1.5.x/include/apr_strings.h
Propchange: apr/apr/branches/1.5.x/
------------------------------------------------------------------------------
Merged /apr/apr/trunk:r1103310,1341193
Modified: apr/apr/branches/1.5.x/include/apr_allocator.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/include/apr_allocator.h?rev=1343250&r1=1343249&r2=1343250&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/include/apr_allocator.h (original)
+++ apr/apr/branches/1.5.x/include/apr_allocator.h Mon May 28 13:34:45 2012
@@ -71,7 +71,8 @@ struct apr_memnode_t {
* @param allocator The allocator we have just created.
*
*/
-APR_DECLARE(apr_status_t) apr_allocator_create(apr_allocator_t **allocator);
+APR_DECLARE(apr_status_t) apr_allocator_create(apr_allocator_t **allocator)
+ __attribute__((nonnull(1)));
/**
* Destroy an allocator
@@ -79,7 +80,8 @@ APR_DECLARE(apr_status_t) apr_allocator_
* @remark Any memnodes not given back to the allocator prior to destroying
* will _not_ be free()d.
*/
-APR_DECLARE(void) apr_allocator_destroy(apr_allocator_t *allocator);
+APR_DECLARE(void) apr_allocator_destroy(apr_allocator_t *allocator)
+ __attribute__((nonnull(1)));
/**
* Allocate a block of mem from the allocator
@@ -88,7 +90,8 @@ APR_DECLARE(void) apr_allocator_destroy(
* memnode structure)
*/
APR_DECLARE(apr_memnode_t *) apr_allocator_alloc(apr_allocator_t *allocator,
- apr_size_t size);
+ apr_size_t size)
+ __attribute__((nonnull(1)));
/**
* Free a list of blocks of mem, giving them back to the allocator.
@@ -98,7 +101,8 @@ APR_DECLARE(apr_memnode_t *) apr_allocat
* @param memnode The memory node to return
*/
APR_DECLARE(void) apr_allocator_free(apr_allocator_t *allocator,
- apr_memnode_t *memnode);
+ apr_memnode_t *memnode)
+ __attribute__((nonnull(1,2)));
#include "apr_pools.h"
@@ -114,13 +118,15 @@ APR_DECLARE(void) apr_allocator_free(apr
* the allocator will never be destroyed.
*/
APR_DECLARE(void) apr_allocator_owner_set(apr_allocator_t *allocator,
- apr_pool_t *pool);
+ apr_pool_t *pool)
+ __attribute__((nonnull(1)));
/**
* Get the current owner of the allocator
* @param allocator The allocator to get the owner from
*/
-APR_DECLARE(apr_pool_t *) apr_allocator_owner_get(apr_allocator_t *allocator);
+APR_DECLARE(apr_pool_t *) apr_allocator_owner_get(apr_allocator_t *allocator)
+ __attribute__((nonnull(1)));
/**
* Set the current threshold at which the allocator should start
@@ -129,7 +135,8 @@ APR_DECLARE(apr_pool_t *) apr_allocator_
* @param size The threshold. 0 == unlimited.
*/
APR_DECLARE(void) apr_allocator_max_free_set(apr_allocator_t *allocator,
- apr_size_t size);
+ apr_size_t size)
+ __attribute__((nonnull(1)));
#include "apr_thread_mutex.h"
@@ -140,14 +147,16 @@ APR_DECLARE(void) apr_allocator_max_free
* @param mutex The mutex
*/
APR_DECLARE(void) apr_allocator_mutex_set(apr_allocator_t *allocator,
- apr_thread_mutex_t *mutex);
+ apr_thread_mutex_t *mutex)
+ __attribute__((nonnull(1)));
/**
* Get the mutex currently set for the allocator
* @param allocator The allocator
*/
APR_DECLARE(apr_thread_mutex_t *) apr_allocator_mutex_get(
- apr_allocator_t *allocator);
+ apr_allocator_t *allocator)
+ __attribute__((nonnull(1)));
#endif /* APR_HAS_THREADS */
Modified: apr/apr/branches/1.5.x/include/apr_pools.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/include/apr_pools.h?rev=1343250&r1=1343249&r2=1343250&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/include/apr_pools.h (original)
+++ apr/apr/branches/1.5.x/include/apr_pools.h Mon May 28 13:34:45 2012
@@ -196,7 +196,8 @@ APR_DECLARE(void) apr_pool_terminate(voi
APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool,
apr_pool_t *parent,
apr_abortfunc_t abort_fn,
- apr_allocator_t *allocator);
+ apr_allocator_t *allocator)
+ __attribute__((nonnull(1)));
/**
* Create a new pool.
@@ -220,7 +221,8 @@ APR_DECLARE(apr_status_t) apr_pool_creat
*/
APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex(apr_pool_t **newpool,
apr_abortfunc_t abort_fn,
- apr_allocator_t *allocator);
+ apr_allocator_t *allocator)
+ __attribute__((nonnull(1)));
/**
* Debug version of apr_pool_create_ex.
@@ -242,7 +244,8 @@ APR_DECLARE(apr_status_t) apr_pool_creat
apr_pool_t *parent,
apr_abortfunc_t abort_fn,
apr_allocator_t *allocator,
- const char *file_line);
+ const char *file_line)
+ __attribute__((nonnull(1)));
#if APR_POOL_DEBUG
#define apr_pool_create_ex(newpool, parent, abort_fn, allocator) \
@@ -277,7 +280,8 @@ APR_DECLARE(apr_status_t) apr_pool_creat
APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex_debug(apr_pool_t **newpool,
apr_abortfunc_t abort_fn,
apr_allocator_t *allocator,
- const char *file_line);
+ const char *file_line)
+ __attribute__((nonnull(1)));
#if APR_POOL_DEBUG
#define apr_pool_create_core_ex(newpool, abort_fn, allocator) \
@@ -343,7 +347,8 @@ APR_DECLARE(apr_status_t) apr_pool_creat
* Find the pool's allocator
* @param pool The pool to get the allocator from.
*/
-APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool);
+APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool)
+ __attribute__((nonnull(1)));
/**
* Clear all memory in the pool and run all the cleanups. This also destroys all
@@ -353,7 +358,7 @@ APR_DECLARE(apr_allocator_t *) apr_pool_
* to re-use this memory for the next allocation.
* @see apr_pool_destroy()
*/
-APR_DECLARE(void) apr_pool_clear(apr_pool_t *p);
+APR_DECLARE(void) apr_pool_clear(apr_pool_t *p) __attribute__((nonnull(1)));
/**
* Debug version of apr_pool_clear.
@@ -369,7 +374,8 @@ APR_DECLARE(void) apr_pool_clear(apr_poo
* and don't call apr_pool_destroy_clear directly.
*/
APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *p,
- const char *file_line);
+ const char *file_line)
+ __attribute__((nonnull(1)));
#if APR_POOL_DEBUG
#define apr_pool_clear(p) \
@@ -382,7 +388,7 @@ APR_DECLARE(void) apr_pool_clear_debug(a
* @param p The pool to destroy
* @remark This will actually free the memory
*/
-APR_DECLARE(void) apr_pool_destroy(apr_pool_t *p);
+APR_DECLARE(void) apr_pool_destroy(apr_pool_t *p) __attribute__((nonnull(1)));
/**
* Debug version of apr_pool_destroy.
@@ -398,7 +404,8 @@ APR_DECLARE(void) apr_pool_destroy(apr_p
* and don't call apr_pool_destroy_debug directly.
*/
APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *p,
- const char *file_line);
+ const char *file_line)
+ __attribute__((nonnull(1)));
#if APR_POOL_DEBUG
#define apr_pool_destroy(p) \
@@ -416,7 +423,11 @@ APR_DECLARE(void) apr_pool_destroy_debug
* @param size The amount of memory to allocate
* @return The allocated memory
*/
-APR_DECLARE(void *) apr_palloc(apr_pool_t *p, apr_size_t size);
+APR_DECLARE(void *) apr_palloc(apr_pool_t *p, apr_size_t size)
+#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+ __attribute__((alloc_size(2)))
+#endif
+ __attribute__((nonnull(1)));
/**
* Debug version of apr_palloc
@@ -427,7 +438,11 @@ APR_DECLARE(void *) apr_palloc(apr_pool_
* @return See: apr_palloc
*/
APR_DECLARE(void *) apr_palloc_debug(apr_pool_t *p, apr_size_t size,
- const char *file_line);
+ const char *file_line)
+#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+ __attribute__((alloc_size(2)))
+#endif
+ __attribute__((nonnull(1)));
#if APR_POOL_DEBUG
#define apr_palloc(p, size) \
@@ -455,7 +470,8 @@ APR_DECLARE(void *) apr_pcalloc(apr_pool
* @return See: apr_pcalloc
*/
APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *p, apr_size_t size,
- const char *file_line);
+ const char *file_line)
+ __attribute__((nonnull(1)));
#if APR_POOL_DEBUG
#define apr_pcalloc(p, size) \
@@ -476,21 +492,24 @@ APR_DECLARE(void *) apr_pcalloc_debug(ap
* deal with the error accordingly.
*/
APR_DECLARE(void) apr_pool_abort_set(apr_abortfunc_t abortfunc,
- apr_pool_t *pool);
+ apr_pool_t *pool)
+ __attribute__((nonnull(2)));
/**
* Get the abort function associated with the specified pool.
* @param pool The pool for retrieving the abort function.
* @return The abort function for the given pool.
*/
-APR_DECLARE(apr_abortfunc_t) apr_pool_abort_get(apr_pool_t *pool);
+APR_DECLARE(apr_abortfunc_t) apr_pool_abort_get(apr_pool_t *pool)
+ __attribute__((nonnull(1)));
/**
* Get the parent pool of the specified pool.
* @param pool The pool for retrieving the parent pool.
* @return The parent of the given pool.
*/
-APR_DECLARE(apr_pool_t *) apr_pool_parent_get(apr_pool_t *pool);
+APR_DECLARE(apr_pool_t *) apr_pool_parent_get(apr_pool_t *pool)
+ __attribute__((nonnull(1)));
/**
* Determine if pool a is an ancestor of pool b.
@@ -510,7 +529,8 @@ APR_DECLARE(int) apr_pool_is_ancestor(ap
* @param pool The pool to tag
* @param tag The tag
*/
-APR_DECLARE(void) apr_pool_tag(apr_pool_t *pool, const char *tag);
+APR_DECLARE(void) apr_pool_tag(apr_pool_t *pool, const char *tag)
+ __attribute__((nonnull(1)));
/*
@@ -536,11 +556,11 @@ APR_DECLARE(void) apr_pool_tag(apr_pool_
* key names is a typical way to help ensure this uniqueness.
*
*/
-APR_DECLARE(apr_status_t) apr_pool_userdata_set(
- const void *data,
- const char *key,
- apr_status_t (*cleanup)(void *),
- apr_pool_t *pool);
+APR_DECLARE(apr_status_t) apr_pool_userdata_set(const void *data,
+ const char *key,
+ apr_status_t (*cleanup)(void *),
+ apr_pool_t *pool)
+ __attribute__((nonnull(2,4)));
/**
* Set the data associated with the current pool
@@ -562,10 +582,10 @@ APR_DECLARE(apr_status_t) apr_pool_userd
*
*/
APR_DECLARE(apr_status_t) apr_pool_userdata_setn(
- const void *data,
- const char *key,
- apr_status_t (*cleanup)(void *),
- apr_pool_t *pool);
+ const void *data, const char *key,
+ apr_status_t (*cleanup)(void *),
+ apr_pool_t *pool)
+ __attribute__((nonnull(2,4)));
/**
* Return the data associated with the current pool.
@@ -574,7 +594,8 @@ APR_DECLARE(apr_status_t) apr_pool_userd
* @param pool The current pool.
*/
APR_DECLARE(apr_status_t) apr_pool_userdata_get(void **data, const char *key,
- apr_pool_t *pool);
+ apr_pool_t *pool)
+ __attribute__((nonnull(1,2,3)));
/**
@@ -601,10 +622,10 @@ APR_DECLARE(apr_status_t) apr_pool_userd
* to exec - this function is called in the child, obviously!
*/
APR_DECLARE(void) apr_pool_cleanup_register(
- apr_pool_t *p,
- const void *data,
- apr_status_t (*plain_cleanup)(void *),
- apr_status_t (*child_cleanup)(void *));
+ apr_pool_t *p, const void *data,
+ apr_status_t (*plain_cleanup)(void *),
+ apr_status_t (*child_cleanup)(void *))
+ __attribute__((nonnull(3,4)));
/**
* Register a function to be called when a pool is cleared or destroyed.
@@ -619,9 +640,9 @@ APR_DECLARE(void) apr_pool_cleanup_regis
* or destroyed
*/
APR_DECLARE(void) apr_pool_pre_cleanup_register(
- apr_pool_t *p,
- const void *data,
- apr_status_t (*plain_cleanup)(void *));
+ apr_pool_t *p, const void *data,
+ apr_status_t (*plain_cleanup)(void *))
+ __attribute__((nonnull(3)));
/**
* Remove a previously registered cleanup function.
@@ -636,7 +657,8 @@ APR_DECLARE(void) apr_pool_pre_cleanup_r
* function
*/
APR_DECLARE(void) apr_pool_cleanup_kill(apr_pool_t *p, const void *data,
- apr_status_t (*cleanup)(void *));
+ apr_status_t (*cleanup)(void *))
+ __attribute__((nonnull(3)));
/**
* Replace the child cleanup function of a previously registered cleanup.
@@ -651,10 +673,10 @@ APR_DECLARE(void) apr_pool_cleanup_kill(
* @param child_cleanup The function to register as the child cleanup
*/
APR_DECLARE(void) apr_pool_child_cleanup_set(
- apr_pool_t *p,
- const void *data,
- apr_status_t (*plain_cleanup)(void *),
- apr_status_t (*child_cleanup)(void *));
+ apr_pool_t *p, const void *data,
+ apr_status_t (*plain_cleanup)(void *),
+ apr_status_t (*child_cleanup)(void *))
+ __attribute__((nonnull(3,4)));
/**
* Run the specified cleanup function immediately and unregister it.
@@ -667,10 +689,9 @@ APR_DECLARE(void) apr_pool_child_cleanup
* @param data The data to remove from cleanup
* @param cleanup The function to remove from cleanup
*/
-APR_DECLARE(apr_status_t) apr_pool_cleanup_run(
- apr_pool_t *p,
- void *data,
- apr_status_t (*cleanup)(void *));
+APR_DECLARE(apr_status_t) apr_pool_cleanup_run(apr_pool_t *p, void *data,
+ apr_status_t (*cleanup)(void *))
+ __attribute__((nonnull(3)));
/**
* An empty cleanup function.
@@ -739,7 +760,8 @@ APR_DECLARE(void) apr_pool_cleanup_for_e
* @param p The parent pool
* @param sub The subpool
*/
-APR_DECLARE(void) apr_pool_join(apr_pool_t *p, apr_pool_t *sub);
+APR_DECLARE(void) apr_pool_join(apr_pool_t *p, apr_pool_t *sub)
+ __attribute__((nonnull(2)));
/**
* Find a pool from something allocated in it.
@@ -754,7 +776,8 @@ APR_DECLARE(apr_pool_t *) apr_pool_find(
* @param recurse Recurse/include the subpools' sizes
* @return The number of bytes
*/
-APR_DECLARE(apr_size_t) apr_pool_num_bytes(apr_pool_t *p, int recurse);
+APR_DECLARE(apr_size_t) apr_pool_num_bytes(apr_pool_t *p, int recurse)
+ __attribute__((nonnull(1)));
/**
* Lock a pool
Modified: apr/apr/branches/1.5.x/include/apr_strings.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/include/apr_strings.h?rev=1343250&r1=1343249&r2=1343250&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/include/apr_strings.h (original)
+++ apr/apr/branches/1.5.x/include/apr_strings.h Mon May 28 13:34:45 2012
@@ -106,7 +106,11 @@ APR_DECLARE(char *) apr_pstrdup(apr_pool
* has 'n' or more characters. If the string might contain
* fewer characters, use apr_pstrndup.
*/
-APR_DECLARE(char *) apr_pstrmemdup(apr_pool_t *p, const char *s, apr_size_t n);
+APR_DECLARE(char *) apr_pstrmemdup(apr_pool_t *p, const char *s, apr_size_t n)
+#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+ __attribute__((alloc_size(3)))
+#endif
+ ;
/**
* Duplicate at most n characters of a string into memory allocated
@@ -128,7 +132,11 @@ APR_DECLARE(char *) apr_pstrndup(apr_poo
* @param n The number of bytes to duplicate
* @return The new block of memory
*/
-APR_DECLARE(void *) apr_pmemdup(apr_pool_t *p, const void *m, apr_size_t n);
+APR_DECLARE(void *) apr_pmemdup(apr_pool_t *p, const void *m, apr_size_t n)
+#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+ __attribute__((alloc_size(3)))
+#endif
+ ;
/**
* Concatenate multiple strings, allocating memory out a pool