void conf_roster_free_call_conference (cc_call_conference_Info_t *confInfo) { cc_call_conferenceParticipant_Info_t *participant; CCAPP_DEBUG(DEB_F_PREFIX"in free_call_confrerence \n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, "CCAPI-CONFPARSE")); while((participant=(cc_call_conferenceParticipant_Info_t *) sll_lite_unlink_head(&confInfo->currentParticipantsList)) != NULL) { strlib_free(participant->participantName); strlib_free(participant->endpointUri); strlib_free(participant->callid); strlib_free(participant->participantNumber); participant->participantSecurity = CC_SECURITY_NONE; participant->participantStatus = CCAPI_CONFPARTICIPANT_UNKNOWN; participant->canRemoveOtherParticipants = FALSE; cpr_free(participant); participant = NULL; } strlib_free(confInfo->myParticipantId); conf_roster_init_call_conference(confInfo); }
/** * Before initing the line_info release any memory which has been used * so we do not leak any here. */ void ccsnap_line_pre_init () { int i; CCAPP_DEBUG(DEB_F_PREFIX"Entering line_pre_init to clear it out to avoid mem leaks\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, "ccsnap_line_pre_init")); for (i=1;i<MAX_CONFIG_LINES;i++) { if ((lineInfo[i].name) && (strlen(lineInfo[i].name) > 0)) { strlib_free(lineInfo[i].name); } if ((lineInfo[i].dn) && (strlen(lineInfo[i].dn) > 0)) { strlib_free(lineInfo[i].dn); } if ((lineInfo[i].cfwd_dest) && (strlen(lineInfo[i].cfwd_dest) > 0)) { strlib_free(lineInfo[i].cfwd_dest); } if ((lineInfo[i].externalNumber) && (strlen(lineInfo[i].externalNumber) > 0)) { strlib_free(lineInfo[i].externalNumber); } if ((featureInfo[i].speedDialNumber) && (strlen(featureInfo[i].speedDialNumber) > 0)) { strlib_free(featureInfo[i].speedDialNumber); } if ((featureInfo[i].contact) && (strlen(featureInfo[i].contact) > 0)) { strlib_free(featureInfo[i].contact); } if ((featureInfo[i].name) && (strlen(featureInfo[i].name) > 0)) { strlib_free(featureInfo[i].name); } if ((featureInfo[i].retrievalPrefix) && (strlen(featureInfo[i].retrievalPrefix) > 0)) { strlib_free(featureInfo[i].retrievalPrefix); } } }
/* * Function: strlib_open * * PARAMETERS: string_t : string to be modified * int : length of string to be modified * * DESCRIPTION:User will call open when he wants to modify the string. If * length of string after modification is going to be = < original string * return to him pointer to original string, else a new string is malloced * for user and a pointer to it is send to him. * * RETURNS: char* to modifiable string * */ char * strlib_open (string_t str, int length, const char *fname, int line) { char *ret_str; string_block_t *temp; if (!strlib_is_string(str)) { return (NULL); } temp = STR_TO_STRUCT(str); if ((temp->refcount == 1) && (length <= temp->length)) { ret_str = (char *) str; } else { ret_str = (char *) strlib_malloc(str, length, fname, line); if (!ret_str) { /* * If a malloc error occurred, give them back what they had. * It's not right, but it's better than nothing. */ ret_str = (char *) str; } else { strlib_free(str); } } return (ret_str); }
/** * Release any used mem to avoid a leak. */ void ccsnap_device_pre_init () { int i = 0; CCAPP_DEBUG(DEB_F_PREFIX"Entering device_pre_init to clear it out to avoid mem leaks", DEB_F_PREFIX_ARGS(SIP_CC_PROV, "ccsnap_device_pre_init")); if ((g_deviceInfo.not_prompt) && (strlen(g_deviceInfo.not_prompt) > 0)) { strlib_free(g_deviceInfo.not_prompt); } i = 0; while (i < CCAPI_MAX_SERVERS) { if ((g_deviceInfo.ucm[i].name) && (strlen(g_deviceInfo.ucm[i].name) > 0)) { strlib_free(g_deviceInfo.ucm[i].name); } i++; } }
/* * Function: strlib_update * * PARAMETERS:string_t : destination string * const char* : source string * * DESCRIPTION:like strcpy but returns const char* to a string in pool * * RETURNS: string_t:Pointer to a new string * */ string_t strlib_update (string_t destination, const char *source, const char *calling_fname, int line) { const char *fname = "strlib_udpate"; string_t ret_str; /* Bogus destination */ if (!destination) { /* Should never happen, so report it */ err_msg("%s: Destination String is invalid: %s:%d", fname, calling_fname, line); /* bad input, bad output */ return NULL; } /* Bogus source */ if (!source) { /* Should never happen, so report it and return something */ err_msg("%s: Source String is invalid: %s:%d", fname, calling_fname, line); strlib_free(destination); return strlib_empty(); } if (source[0] == '\0') { /* Source is NULL string, use string empty */ strlib_free(destination); return strlib_empty(); } ret_str = strlib_malloc(source, LEN_UNKNOWN, calling_fname, line); if (!ret_str) { /* * If a malloc error occurred, give them back what they had. * It's not right, but it's better than nothing. */ ret_str = destination; } else { strlib_free(destination); } return (ret_str); }
/** * Inserts localized strings into existing strings with escape characters. * @param destination the return phrase holder * @param source the phrase with escape characters. * @param len the input length to cap the maximum value * @return pointer to the new string */ cc_string_t ccsnap_EscapeStrToLocaleStr(cc_string_t destination, cc_string_t source, int len) { static const char *fname="ccsnap_EscapeStrToLocaleStr"; char phrase_collector[MAX_LOCALE_STRING_LEN] = { '\0' }; char* phrase_collector_ptr = phrase_collector; char* esc_string_itr = (char*)source; int remaining_length = 0; cc_string_t ret_str = strlib_empty(); if(destination == NULL){ CCAPP_DEBUG(DEB_F_PREFIX"Error: destination is NULL\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname)); return NULL; } if(source == NULL){ CCAPP_DEBUG(DEB_F_PREFIX"Error: source is NULL\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname)); strlib_free(destination); return strlib_empty(); } if(source[0] == '\0'){ strlib_free(destination); return strlib_empty(); } if (len == LEN_UNKNOWN) { len = strlen(source) + MAX_LOCALE_PHRASE_LEN; } if (len <= 0){ CCAPP_DEBUG(DEB_F_PREFIX"Error: cannot write string of length <= 0\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname)); strlib_free(destination); return strlib_empty(); } if (len > MAX_LOCALE_STRING_LEN){ len = MAX_LOCALE_STRING_LEN; } remaining_length = len; while( *esc_string_itr != NUL && remaining_length > 0 && strlen(phrase_collector_ptr) < (size_t)(len-1)) { int rtn = CC_SUCCESS; int phrase_index = 0; char* phrase_bucket_ptr = (char*)cpr_malloc(remaining_length * sizeof(char)); if (phrase_bucket_ptr == NULL) { CCAPP_ERROR(DEB_F_PREFIX"Error: phrase_bucket_ptr is NULL\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname)); strlib_free(destination); return NULL; } phrase_bucket_ptr[0] = '\0'; switch(*esc_string_itr){ case OLD_CUCM_DICTIONARY_ESCAPE_TAG: phrase_index += CALL_CONTROL_PHRASE_OFFSET; // Do not set break to combine common code case NEW_CUCM_DICTIONARY_ESCAPE_TAG: esc_string_itr++; phrase_index += (int)(*esc_string_itr); rtn = platGetPhraseText(phrase_index, phrase_bucket_ptr, remaining_length-1); if(rtn == CC_FAILURE) break; sstrncat(phrase_collector_ptr, (cc_string_t)phrase_bucket_ptr, remaining_length); remaining_length--; break; default: // We need length 2 to concat 1 char and a terminating char sstrncat(phrase_collector_ptr, esc_string_itr, 1 + sizeof(char)); remaining_length--; break; } esc_string_itr++; cpr_free(phrase_bucket_ptr); } ret_str = strlib_malloc(phrase_collector_ptr, len); if (!ret_str) { /* * If a malloc error occurred, give them back what they had. * It's not right, but it's better than nothing. */ ret_str = destination; } else { strlib_free(destination); } CCAPP_DEBUG(DEB_F_PREFIX"Localization String returning %s\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname), ret_str); return (ret_str); }