Jabberd14-1.6.0/jabberd/lib/pool.c/_retried__malloc

Last-modified: 2007-03-05 (月) 21:18:02

このページを編集する際は,編集に関する方針に従ってください.

概要

 * try to allocate memory
 *
 * If allocation fails, it will be retries for MAX_MALLOC_TRIES seconds.
 * If it still fails, we exit the process

引数

 * @param size how many bytes of memory we allocate
 * @return pointer to the allocated memory

実装

#define MAX_MALLOC_TRIES 10 /**< how many seconds we try to allocate memory */
inline void *_retried__malloc(size_t size) {
    void *allocated_memory;
    int malloc_tries = 0;
    while ((allocated_memory=_pool__malloc(size)) == NULL) {
	 if (malloc_tries++ > MAX_MALLOC_TRIES) {
	     exit(999);
	 }
	 pth_sleep(1);
    }
    return allocated_memory;
}

呼出元

Jabberd14-1.6.0/jabberd/lib/pool.c/pmalloc
Jabberd14-1.6.0/jabberd/lib/pool.c/_pool_free

#related: relatedプラグインは廃止されました。