From 148070985fd49efeebfb3a93865a6503d8b1dd4c Mon Sep 17 00:00:00 2001 From: Chernov Dmitriy <cd_work@mail.ru> Date: 周一, 29 2月 2016 16:01:24 +0800 Subject: [PATCH] strdup(malloc)/free ready. --- libscpi/inc/scpi/config.h | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-) diff --git a/libscpi/inc/scpi/config.h b/libscpi/inc/scpi/config.h index c2c95d4..75b9731 100644 --- a/libscpi/inc/scpi/config.h +++ b/libscpi/inc/scpi/config.h @@ -91,11 +91,12 @@ #ifndef USE_DEVICE_DEPENDENT_ERROR_INFORMATION #define USE_DEVICE_DEPENDENT_ERROR_INFORMATION 1 + #ifndef USE_MEMORY_ALLOCATION_FREE + #define USE_MEMORY_ALLOCATION_FREE 1 + #endif #endif -#ifndef USE_MEMORY_ALLOCATION_FREE -#define USE_MEMORY_ALLOCATION_FREE 1 -#endif + #ifndef USE_COMMAND_TAGS #define USE_COMMAND_TAGS 1 @@ -259,17 +260,20 @@ #if USE_DEVICE_DEPENDENT_ERROR_INFORMATION #if USE_MEMORY_ALLOCATION_FREE + #include <stdlib.h> #include <string.h> #include <malloc.h> - #define SCPIDEFINE_strdup(s) strdup((s)) - #define SCPIDEFINE_free(s) free((s)) + #define SCPIDEFINE_strdup(h,s) strdup((s)) + #define SCPIDEFINE_free(h,s) free((s)) #else - #define SCPIDEFINE_strdup(s) NULL - #define SCPIDEFINE_free(s) NULL + #define SCPIDEFINE_strdup(h,s) OUR_strdup((h), (s)) + #define SCPIDEFINE_free(h,s) OUR_free((h), (s)) + #define SCPIDEFINE_get_1st_part(s,l) OUR_get_1st_part((s),(l)) + #define SCPIDEFINE_get_2st_part(s,l) OUR_get_2nd_part((s),(l)) #endif #else - #define SCPIDEFINE_strdup(s) NULL - #define SCPIDEFINE_free(s) NULL + #define SCPIDEFINE_strdup(h,s) (void)(s) + #define SCPIDEFINE_free(h,s) (void)(s) #endif #ifdef __cplusplus -- Gitblit v1.9.1