comparison src/protocols/jabber/pool.c @ 3127:4e7cefc55971

[gaim-migrate @ 3142] Upgraded jabber to most recent stable version committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Thu, 04 Apr 2002 03:04:57 +0000
parents 424a40f12a6c
children 988485669631
comparison
equal deleted inserted replaced
3126:e883f604174e 3127:4e7cefc55971
1 /* 1 /* --------------------------------------------------------------------------
2 * This program is free software; you can redistribute it and/or modify 2 *
3 * it under the terms of the GNU General Public License as published by 3 * License
4 * the Free Software Foundation; either version 2 of the License, or 4 *
5 * (at your option) any later version. 5 * The contents of this file are subject to the Jabber Open Source License
6 * 6 * Version 1.0 (the "JOSL"). You may not copy or use this file, in either
7 * This program is distributed in the hope that it will be useful, 7 * source code or executable form, except in compliance with the JOSL. You
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 * may obtain a copy of the JOSL at http://www.jabber.org/ or at
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 * http://www.opensource.org/.
10 * GNU General Public License for more details. 10 *
11 * 11 * Software distributed under the JOSL is distributed on an "AS IS" basis,
12 * You should have received a copy of the GNU General Public License 12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the JOSL
13 * along with this program; if not, write to the Free Software 13 * for the specific language governing rights and limitations under the
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 14 * JOSL.
15 * 15 *
16 * Jabber 16 * Copyrights
17 * Copyright (C) 1998-1999 The Jabber Team http://jabber.org/ 17 *
18 * 18 * Portions created by or assigned to Jabber.com, Inc. are
19 * 2/27/00:3am, random plans by jer 19 * Copyright (c) 1999-2002 Jabber.com, Inc. All Rights Reserved. Contact
20 * 20 * information for Jabber.com, Inc. is available at http://www.jabber.com/.
21 * ok based on gprof, we really need some innovation here... my thoughs are this: 21 *
22 * 22 * Portions Copyright (c) 1998-1999 Jeremie Miller.
23 * most things are strings, so have a string-based true-blue garbage collector 23 *
24 * one big global hash containing all the strings created by any pstrdup, returning const char * 24 * Acknowledgements
25 * a refcount on each string block 25 *
26 * when a pool is freed, it moves down the refcount 26 * Special thanks to the Jabber Open Source Contributors for their
27 * garbage collector collects pools on the free stack, and runs through the hash for unused strings 27 * suggestions and support of Jabber.
28 * j_strcmp can check for == (if they are both from a pstrdup) 28 *
29 * 29 * Alternatively, the contents of this file may be used under the terms of the
30 * let's see... this would change: 30 * GNU General Public License Version 2 or later (the "GPL"), in which case
31 * pstrdup: do a hash lookup, success=return, fail=pmalloc & hash put 31 * the provisions of the GPL are applicable instead of those above. If you
32 * pool_free: 32 * wish to allow use of your version of this file only under the terms of the
33 * 33 * GPL and not to allow others to use your version of this file under the JOSL,
34 * 34 * indicate your decision by deleting the provisions above and replace them
35 * 35 * with the notice and other provisions required by the GPL. If you do not
36 * 36 * delete the provisions above, a recipient may use your version of this file
37 * 37 * under either the JOSL or the GPL.
38 */ 38 *
39 39 *
40 #include "libxode.h" 40 * --------------------------------------------------------------------------*/
41 #include "config.h" 41
42 #include "lib.h"
42 43
43 44
44 #ifdef POOL_DEBUG 45 #ifdef POOL_DEBUG
45 int pool__total = 0; 46 int pool__total = 0;
46 int pool__ltotal = 0; 47 int pool__ltotal = 0;
75 p->zone[0] = '\0'; 76 p->zone[0] = '\0';
76 strcat(p->zone,zone); 77 strcat(p->zone,zone);
77 sprintf(p->name,"%X",p); 78 sprintf(p->name,"%X",p);
78 79
79 if(pool__disturbed == NULL) 80 if(pool__disturbed == NULL)
81 {
82 pool__disturbed = 1; /* reentrancy flag! */
80 pool__disturbed = ghash_create(POOL_DEBUG,(KEYHASHFUNC)str_hash_code,(KEYCOMPAREFUNC)j_strcmp); 83 pool__disturbed = ghash_create(POOL_DEBUG,(KEYHASHFUNC)str_hash_code,(KEYCOMPAREFUNC)j_strcmp);
81 ghash_put(pool__disturbed,p->name,p); 84 }
85 if(pool__disturbed != 1)
86 ghash_put(pool__disturbed,p->name,p);
82 #endif 87 #endif
83 88
84 return p; 89 return p;
85 } 90 }
86 91