Debian Codegraph @

src/vendor/azure-uamqp-c/deps/umock-c/devdoc/umockcallpairs_requirements.md

raw
1
2 # umockcallpairs requirements
3
4 # Overview
5
6 umockcallpairs is a module that handles tracking of call pairs.
7
8 # Exposed API
9
10 ```c
11 typedef struct PAIRED_HANDLE_TAG
12 {
13 void* handle_value;
14 char* handle_type;
15 } PAIRED_HANDLE;
16
17 typedef struct PAIRED_HANDLES_TAG
18 {
19 PAIRED_HANDLE* paired_handles;
20 size_t paired_handle_count;
21 } PAIRED_HANDLES;
22
23 int umockcallpairs_track_create_paired_call(PAIRED_HANDLES* paired_handles, const void* handle, const char* handle_type, size_t handle_type_size);
24 int umockcallpairs_track_destroy_paired_call(PAIRED_HANDLES* paired_handles, const void* handle);
25 ```
26
27 ## umockcallpairs_track_create_paired_call
28
29 ```c
30 int umockcallpairs_track_create_paired_call(PAIRED_HANDLES* paired_handles, const void* handle, const char* handle_type, size_t handle_type_size);
31 ```
32
33 **SRS_UMOCKCALLPAIRS_01_001: [** umockcallpairs_track_create_paired_call shall add a new entry to the PAIRED_HANDLES array and on success it shall return 0. **]**
34
35 **SRS_UMOCKCALLPAIRS_01_002: [** umockcallpairs_track_create_paired_call shall copy the handle_value to the handle_value member of the new entry. **]**
36
37 **SRS_UMOCKCALLPAIRS_01_003: [** umockcallpairs_track_create_paired_call shall allocate a memory block and store a pointer to it in the memory field of the new entry. **]**
38
39 **SRS_UMOCKCALLPAIRS_01_004: [** If any of the arguments paired_handles, handle or handle_type is NULL, umockcallpairs_track_create_paired_call shallfail and return a non-zero value. **]**
40
41 **SRS_UMOCKCALLPAIRS_01_005: [** If allocating memory fails, umockcallpairs_track_create_paired_call shall fail and return a non-zero value. **]**
42
43 **SRS_UMOCKCALLPAIRS_01_006: [** The handle value shall be copied by using umocktypes_copy. **]**
44
45 **SRS_UMOCKCALLPAIRS_01_007: [** If umocktypes_copy fails, umockcallpairs_track_create_paired_call shall fail and return a non-zero value. **]**
46
47 ## umockcallpairs_track_destroy_paired_call
48
49 ```c
50 int umockcallpairs_track_destroy_paired_call(PAIRED_HANDLES* paired_handles, const void* handle);
51 ```
52
53 **SRS_UMOCKCALLPAIRS_01_008: [** umockcallpairs_track_destroy_paired_call shall remove from the paired handles array pointed by the paired_handles field the entry that is associated with the handle passed in the handle argument. **]**
54
55 **SRS_UMOCKCALLPAIRS_01_009: [** On success umockcallpairs_track_destroy_paired_call shall return 0. **]**
56
57 **SRS_UMOCKCALLPAIRS_01_010: [** If any of the arguments is NULL, umockcallpairs_track_destroy_paired_call shall fail and return a non-zero value. **]**
58
59 **SRS_UMOCKCALLPAIRS_01_011: [** umockcallpairs_track_destroy_paired_call shall free the memory pointed by the memory field in the PAIRED_HANDLES array entry associated with handle. **]**
60
61 **SRS_UMOCKCALLPAIRS_01_012: [** If the array paired handles array is empty after removing the entry, the paired_handles field shall be freed and set to NULL. **]**
62
63 **SRS_UMOCKCALLPAIRS_01_013: [** When looking up which entry to remove, the comparison of the handle values shall be done by calling umocktypes_are_equal. **]**
64
65 **SRS_UMOCKCALLPAIRS_01_014: [** If umocktypes_are_equal fails, umockcallpairs_track_destroy_paired_call shall fail and return a non-zero value. **]**
66
67 **SRS_UMOCKCALLPAIRS_01_015: [** If the handle is not found in the array then umockcallpairs_track_destroy_paired_call shall fail and return a non-zero value. **]**