MCPcopy Create free account
hub / github.com/OpenPrinting/cups / _cupsStrFree

Function _cupsStrFree

cups/string.c:283–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281 */
282
283void
284_cupsStrFree(const char *s) /* I - String to free */
285{
286 _cups_sp_item_t *item, /* String pool item */
287 *key; /* Search key */
288
289
290 /*
291 * Range check input...
292 */
293
294 if (!s)
295 return;
296
297 /*
298 * Check the string pool...
299 *
300 * We don't need to lock the mutex yet, as we only want to know if
301 * the stringpool is initialized. The rest of the code will still
302 * work if it is initialized before we lock...
303 */
304
305 if (!stringpool)
306 return;
307
308 /*
309 * See if the string is already in the pool...
310 */
311
312 _cupsMutexLock(&sp_mutex);
313
314 key = (_cups_sp_item_t *)(s - offsetof(_cups_sp_item_t, str));
315
316 if ((item = (_cups_sp_item_t *)cupsArrayFind(stringpool, key)) != NULL &&
317 item == key)
318 {
319 /*
320 * Found it, dereference...
321 */
322
323#ifdef DEBUG_GUARDS
324 if (key->guard != _CUPS_STR_GUARD)
325 {
326 DEBUG_printf(("5_cupsStrFree: Freeing string %p(%s), guard=%08x, ref_count=%d", key, key->str, key->guard, key->ref_count));
327 abort();
328 }
329#endif /* DEBUG_GUARDS */
330
331 item->ref_count --;
332
333 if (!item->ref_count)
334 {
335 /*
336 * Remove and free...
337 */
338
339 cupsArrayRemove(stringpool, item);
340

Callers 15

cupsdFreeLocationFunction · 0.85
free_authmaskFunction · 0.85
add_printerFunction · 0.85
update_job_attrsFunction · 0.85
cupsdReadConfigurationFunction · 0.85
cupsdDeletePrinterFunction · 0.85
cupsdSetPrinterAttrFunction · 0.85
cupsdSetPrinterReasonsFunction · 0.85
cupsAddOptionFunction · 0.85
cupsFreeOptionsFunction · 0.85
cupsRemoveOptionFunction · 0.85
cupsSetServerCredentialsFunction · 0.85

Calls 4

_cupsMutexLockFunction · 0.85
cupsArrayFindFunction · 0.85
cupsArrayRemoveFunction · 0.85
_cupsMutexUnlockFunction · 0.85

Tested by

no test coverage detected