Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/caps.c @ 1872:c1d0187f0959
Check for NULL parameters in caps functions
author | franky |
---|---|
date | Mon, 05 Apr 2010 11:40:00 +0200 |
parents | e6d355e50d7a |
children | 1f5015ef43e8 |
comparison
equal
deleted
inserted
replaced
1868:fdb2f88b908b | 1872:c1d0187f0959 |
---|---|
1 /* | 1 /* |
2 * caps.c -- Entity Capabilities Cache for mcabber | 2 * caps.c -- Entity Capabilities Cache for mcabber |
3 * | 3 * |
4 * Copyright (C) 2008 Frank Zschockelt <mcabber@freakysoft.de> | 4 * Copyright (C) 2008-2010 Frank Zschockelt <mcabber@freakysoft.de> |
5 * | 5 * |
6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License as published by | 7 * it under the terms of the GNU General Public License as published by |
8 * the Free Software Foundation; either version 2 of the License, or (at | 8 * the Free Software Foundation; either version 2 of the License, or (at |
9 * your option) any later version. | 9 * your option) any later version. |
73 const char *category, | 73 const char *category, |
74 const char *name, | 74 const char *name, |
75 const char *type) | 75 const char *type) |
76 { | 76 { |
77 caps *c; | 77 caps *c; |
78 if (!hash) | 78 if (!hash || !category || !name || !type) |
79 return; | 79 return; |
80 | 80 |
81 c = g_hash_table_lookup(caps_cache, hash); | 81 c = g_hash_table_lookup(caps_cache, hash); |
82 if (c) { | 82 if (c) { |
83 c->category = g_strdup(category); | 83 c->category = g_strdup(category); |
87 } | 87 } |
88 | 88 |
89 void caps_add_feature(char *hash, const char *feature) | 89 void caps_add_feature(char *hash, const char *feature) |
90 { | 90 { |
91 caps *c; | 91 caps *c; |
92 if (!hash) | 92 if (!hash || !feature) |
93 return; | 93 return; |
94 c = g_hash_table_lookup(caps_cache, hash); | 94 c = g_hash_table_lookup(caps_cache, hash); |
95 if (c) { | 95 if (c) { |
96 char *f = g_strdup(feature); | 96 char *f = g_strdup(feature); |
97 g_hash_table_replace(c->features, f, f); | 97 g_hash_table_replace(c->features, f, f); |
99 } | 99 } |
100 | 100 |
101 int caps_has_feature(char *hash, char *feature) | 101 int caps_has_feature(char *hash, char *feature) |
102 { | 102 { |
103 caps *c; | 103 caps *c; |
104 if (!hash) | 104 if (!hash || !feature) |
105 return 0; | 105 return 0; |
106 c = g_hash_table_lookup(caps_cache, hash); | 106 c = g_hash_table_lookup(caps_cache, hash); |
107 if (c) | 107 if (c) |
108 return (g_hash_table_lookup(c->features, feature) != NULL); | 108 return (g_hash_table_lookup(c->features, feature) != NULL); |
109 return 0; | 109 return 0; |