cvs: pecl /apc apc_cache.c apc_cache.h

From: Date: Thu, 28 Oct 2004 17:41:12 +0000
Subject: cvs: pecl /apc apc_cache.c apc_cache.h
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-1986@lists.php.net to get a copy of this message
rasmus Thu Oct 28 13:41:12 2004 EDT Modified files: /pecl/apc apc_cache.c apc_cache.h Log: Fix apc_fetch() memory leak http://cvs.php.net/diff.php/pecl/apc/apc_cache.c?r1=3.72&r2=3.73&ty=u Index: pecl/apc/apc_cache.c diff -u pecl/apc/apc_cache.c:3.72 pecl/apc/apc_cache.c:3.73 --- pecl/apc/apc_cache.c:3.72 Thu Sep 16 12:49:27 2004 +++ pecl/apc/apc_cache.c Thu Oct 28 13:41:12 2004 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_cache.c,v 3.72 2004/09/16 16:49:27 rasmus Exp $ */ +/* $Id: apc_cache.c,v 3.73 2004/10/28 17:41:12 rasmus Exp $ */ #include "apc_cache.h" #include "apc_lock.h" @@ -109,9 +109,18 @@ /* {{{ make_slot */ slot_t* make_slot(apc_cache_key_t key, apc_cache_entry_t* value, slot_t* next, time_t t) { + char *identifier; slot_t* p = apc_sma_malloc(sizeof(slot_t)); if (!p) return NULL; + if(value->type == APC_CACHE_ENTRY_USER) { + identifier = (char*) apc_xstrdup(key.data.user.identifier, apc_sma_malloc); + if (!identifier) { + apc_sma_free(p); + return NULL; + } + key.data.user.identifier = identifier; + } p->key = key; p->value = value; p->next = next; @@ -126,6 +135,7 @@ /* {{{ free_slot */ static void free_slot(slot_t* slot) { + apc_sma_free(slot->key.data.user.identifier); apc_cache_free_entry(slot->value); apc_sma_free(slot); } @@ -544,14 +554,14 @@ /* }}} */ /* {{{ apc_cache_make_user_key */ -int apc_cache_make_user_key(apc_cache_key_t* key, const char* identifier, const time_t t) +int apc_cache_make_user_key(apc_cache_key_t* key, char* identifier, const time_t t) { assert(key != NULL); if (!identifier) return 0; - key->data.user.identifier = apc_xstrdup(identifier, apc_sma_malloc); + key->data.user.identifier = identifier; key->mtime = t; return 1; } http://cvs.php.net/diff.php/pecl/apc/apc_cache.h?r1=3.21&r2=3.22&ty=u Index: pecl/apc/apc_cache.h diff -u pecl/apc/apc_cache.h:3.21 pecl/apc/apc_cache.h:3.22 --- pecl/apc/apc_cache.h:3.21 Tue Sep 14 00:35:27 2004 +++ pecl/apc/apc_cache.h Thu Oct 28 13:41:12 2004 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_cache.h,v 3.21 2004/09/14 04:35:27 rasmus Exp $ */ +/* $Id: apc_cache.h,v 3.22 2004/10/28 17:41:12 rasmus Exp $ */ #ifndef APC_CACHE_H #define APC_CACHE_H @@ -187,7 +187,7 @@ */ extern apc_cache_entry_t* apc_cache_make_user_entry(const char* info, const zval *val, const unsigned int ttl); -extern int apc_cache_make_user_key(apc_cache_key_t* key, const char* identifier, const time_t t); +extern int apc_cache_make_user_key(apc_cache_key_t* key, char* identifier, const time_t t); /* * Frees all memory associated with an object returned by apc_cache_make_entry

« previous php.pecl.cvs (#1986) next »