]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add realloc OS hooks and fix boost pri CLI
authorMoises Silva <moy@sangoma.com>
Tue, 13 Apr 2010 19:17:32 +0000 (15:17 -0400)
committerMoises Silva <moy@sangoma.com>
Tue, 13 Apr 2010 19:18:18 +0000 (15:18 -0400)
libs/freetdm/cyginstall.sh
libs/freetdm/freetdm.2008.sln
libs/freetdm/mod_freetdm/mod_freetdm.2008.vcproj
libs/freetdm/mod_freetdm/mod_freetdm.c
libs/freetdm/src/ftdm_io.c
libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c
libs/freetdm/src/include/freetdm.h

index 2536889a65d20edf2dc6708ca1cae1b25c7cfb83..932771929865d4915fd5ade33e3f5f1540571ef0 100644 (file)
@@ -3,8 +3,9 @@
 # FreeSWITCH is trunk is located at ../../
 fsdir=../..
 set -x
-cp Debug/*.dll $fsdir/Debug/
 cp Debug/mod/*.dll $fsdir/Debug/mod/
+cp mod_freetdm/Debug/*.pdb $fsdir/Debug/mod/
+cp Debug/*.dll $fsdir/Debug/
 cp Debug/*.pdb $fsdir/Debug/
 echo "FRIENDLY REMINDER: RECOMPILE ftmod_wanpipe WHENEVER YOU INSTALL NEW DRIVERS"
 set +x 
index 363ea1e9963400cc4aa5dec0a0fad9627735be18..75e65722521fb13bbf3380b87e2eadebe7fb6761 100644 (file)
@@ -54,6 +54,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testboost", "msvc\testboost
        EndProjectSection\r
 EndProject\r
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsangomaboost", "msvc\testboost\testsangomaboost.2008.vcproj", "{0DA69C18-4FA1-4E8C-89CE-12498637C5BE}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D}\r
+       EndProjectSection\r
 EndProject\r
 Global\r
        GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
index b59214cf89e7e031913d316f7edf01fb1c90d77b..5ed38903e7c1bd2907429ababbf26b996c3f5ae5 100644 (file)
@@ -72,7 +72,7 @@
                                LinkIncremental="2"
                                AdditionalLibraryDirectories="&quot;../../../w32/Library/$(OutDir)&quot;"
                                GenerateDebugInformation="true"
-                               ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
+                               ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
                                SubSystem="2"
                                RandomizedBaseAddress="1"
                                DataExecutionPrevention="0"
                                LinkIncremental="1"
                                AdditionalLibraryDirectories="&quot;../../../w32/Library/$(OutDir)&quot;"
                                GenerateDebugInformation="true"
-                               ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
+                               ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
                                SubSystem="2"
                                OptimizeReferences="2"
                                EnableCOMDATFolding="2"
                                LinkIncremental="2"
                                AdditionalLibraryDirectories="&quot;../../../w32/Library/$(OutDir)&quot;"
                                GenerateDebugInformation="true"
-                               ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
+                               ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
                                SubSystem="2"
                                RandomizedBaseAddress="1"
                                DataExecutionPrevention="0"
                                LinkIncremental="1"
                                AdditionalLibraryDirectories="&quot;../../../w32/Library/$(OutDir)&quot;"
                                GenerateDebugInformation="true"
-                               ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
+                               ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
                                SubSystem="2"
                                OptimizeReferences="2"
                                EnableCOMDATFolding="2"
index 42793c964afcc12ff88a2152aa885f8c05028e86..b7011b8edcc798e2798cb161cac324f557151a62 100644 (file)
@@ -3108,11 +3108,12 @@ SWITCH_STANDARD_API(ft_function)
                }
                stream->write_function(stream, "+OK gains set to Rx %f and Tx %f\n", rxgain, txgain);
        } else {
+
                char *rply = ftdm_api_execute(cmd, NULL);
                
                if (rply) {
                        stream->write_function(stream, "%s", rply);
-                       free(rply);
+                       ftdm_safe_free(rply);
                } else {
                        stream->write_function(stream, "-ERR Usage: %s\n", FT_SYNTAX);
                }
index fca0b620914951d7533ba874d0d375dc96439f19..8c0744538dae0d644ad5e4965859e6017fcb6c49 100644 (file)
@@ -223,6 +223,14 @@ static __inline__ void *ftdm_std_calloc(void *pool, ftdm_size_t elements, ftdm_s
        return ptr;
 }
 
+static __inline__ void *ftdm_std_realloc(void *pool, void *buff, ftdm_size_t size)
+{
+       buff = realloc(buff, size);
+       pool = NULL;
+       ftdm_assert_return(buff != NULL, NULL, "Out of memory");
+       return buff;
+}
+
 static __inline__ void ftdm_std_free(void *pool, void *ptr)
 {
        pool = NULL;
@@ -235,6 +243,7 @@ FT_DECLARE_DATA ftdm_memory_handler_t g_ftdm_mem_handler =
        /*.pool =*/ NULL,
        /*.malloc =*/ ftdm_std_malloc,
        /*.calloc =*/ ftdm_std_calloc,
+       /*.realloc =*/ ftdm_std_realloc,
        /*.free =*/ ftdm_std_free
 };
 
@@ -4081,7 +4090,7 @@ FT_DECLARE_NONSTD(ftdm_status_t) ftdm_console_stream_write(ftdm_stream_handle_t
                        void *new_data;
 
                        new_len = handle->data_size + need + handle->alloc_chunk;
-                       if ((new_data = realloc(handle->data, new_len))) {
+                       if ((new_data = ftdm_realloc(handle->data, new_len))) {
                                handle->data_size = handle->alloc_len = new_len;
                                handle->data = new_data;
                                buf = handle->data;
index 59088a3c01b17171eb2f0ba4efec1032c599d870..f8e819e6d264850c61fa13e8574b701212ffbe00 100644 (file)
@@ -1798,7 +1798,7 @@ static FIO_API_FUNCTION(ftdm_sangoma_boost_api)
                        if (sigmod_iface) {
                                char *p = strchr(data, ' ');
                                if (++p) {
-                                       char* mydup = strdup(p);
+                                       char* mydup = ftdm_strdup(p);
                                        if(sigmod_iface->exec_api == NULL) {
                                                stream->write_function(stream, "%s does not support api functions\n", sigmod_iface->name);
                                                goto done;
@@ -1807,7 +1807,7 @@ static FIO_API_FUNCTION(ftdm_sangoma_boost_api)
                                        if (sigmod_iface->exec_api(stream, mydup) != FTDM_SUCCESS) {
                                                stream->write_function(stream, "-ERR:failed to execute command:%s\n", mydup);
                                        }
-                                       free(mydup);
+                                       ftdm_safe_free(mydup);
                                }
                                
                                goto done;
index dcf171b3d73711622bc058a307914e8b2578853b..263e79d40f3f6a26ae885f1a296a6a835e52ecd7 100644 (file)
@@ -364,7 +364,7 @@ FT_DECLARE_NONSTD(ftdm_status_t) ftdm_console_stream_raw_write(ftdm_stream_handl
 FT_DECLARE_NONSTD(ftdm_status_t) ftdm_console_stream_write(ftdm_stream_handle_t *handle, const char *fmt, ...);
 
 #define FTDM_CMD_CHUNK_LEN 1024
-#define FTDM_STANDARD_STREAM(s) memset(&s, 0, sizeof(s)); s.data = malloc(FTDM_CMD_CHUNK_LEN); \
+#define FTDM_STANDARD_STREAM(s) memset(&s, 0, sizeof(s)); s.data = ftdm_malloc(FTDM_CMD_CHUNK_LEN); \
        assert(s.data);                                                                                                         \
        memset(s.data, 0, FTDM_CMD_CHUNK_LEN);                                                          \
        s.end = s.data;                                                                                                         \
@@ -681,11 +681,13 @@ FT_DECLARE_DATA extern ftdm_crash_policy_t g_ftdm_crash_policy;
 
 typedef void *(*ftdm_malloc_func_t)(void *pool, ftdm_size_t len);
 typedef void *(*ftdm_calloc_func_t)(void *pool, ftdm_size_t elements, ftdm_size_t len);
+typedef void *(*ftdm_realloc_func_t)(void *pool, void *buff, ftdm_size_t len);
 typedef void (*ftdm_free_func_t)(void *pool, void *ptr);
 typedef struct ftdm_memory_handler {
        void *pool;
        ftdm_malloc_func_t malloc;
        ftdm_calloc_func_t calloc;
+       ftdm_realloc_func_t realloc;
        ftdm_free_func_t free;
 } ftdm_memory_handler_t;
 
@@ -873,6 +875,13 @@ FIO_CODEC_FUNCTION(fio_alaw2ulaw);
 */
 #define ftdm_malloc(chunksize) g_ftdm_mem_handler.malloc(g_ftdm_mem_handler.pool, chunksize)
 
+/*!
+  \brief Reallocates memory
+  \command buff the buffer
+  \command chunksize the chunk size
+*/
+#define ftdm_realloc(buff, chunksize) g_ftdm_mem_handler.realloc(g_ftdm_mem_handler.pool, buff, chunksize)
+
 /*!
   \brief Allocate initialized memory
   \command chunksize the chunk size