call: Size function for helpers that return data with non-explicit size
authorPaul Kocialkowski <contact@paulk.fr>
Sat, 2 Aug 2014 12:29:43 +0000 (14:29 +0200)
committerPaul Kocialkowski <contact@paulk.fr>
Sat, 2 Aug 2014 13:13:29 +0000 (15:13 +0200)
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
include/call.h
samsung-ipc/call.c

index e3f2dc7..4f5d152 100644 (file)
@@ -148,6 +148,8 @@ unsigned char ipc_call_list_count_extract(const void *data, size_t size);
 struct ipc_call_list_entry *ipc_call_list_entry_extract(const void *data,
     size_t size, unsigned int index);
 char *ipc_call_list_entry_number_extract(const struct ipc_call_list_entry *entry);
+size_t ipc_call_burst_dtmf_size_setup(const struct ipc_call_burst_dtmf_request_entry *entries,
+    unsigned char count);
 void *ipc_call_burst_dtmf_setup(const struct ipc_call_burst_dtmf_request_entry *entries,
     unsigned char count);
 
index 37bdc20..b0720ad 100644 (file)
@@ -106,6 +106,19 @@ char *ipc_call_list_entry_number_extract(const struct ipc_call_list_entry *entry
     return number;
 }
 
+size_t ipc_call_burst_dtmf_size_setup(const struct ipc_call_burst_dtmf_request_entry *entries,
+    unsigned char count)
+{
+    size_t size;
+
+    if (entries == NULL)
+        return 0;
+
+    size = sizeof(struct ipc_call_burst_dtmf_request_header) + count * sizeof(struct ipc_call_burst_dtmf_request_entry);
+
+    return size;
+}
+
 void *ipc_call_burst_dtmf_setup(const struct ipc_call_burst_dtmf_request_entry *entries,
     unsigned char count)
 {
@@ -116,7 +129,9 @@ void *ipc_call_burst_dtmf_setup(const struct ipc_call_burst_dtmf_request_entry *
     if (entries == NULL)
         return NULL;
 
-    size = sizeof(struct ipc_call_burst_dtmf_request_header) + count * sizeof(struct ipc_call_burst_dtmf_request_entry);
+    size = ipc_call_burst_dtmf_size_setup(entries, count);
+    if (size == 0)
+        return NULL;
 
     data = calloc(1, size);