| 1 |
// Copyright (c) Microsoft. All rights reserved. |
| 2 |
// Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 3 |
|
| 4 |
#include <stddef.h> |
| 5 |
#include "azure_c_shared_utility/refcount.h" |
| 6 |
#include "some_refcount_impl.h" |
| 7 |
|
| 8 |
typedef struct pos_TAG |
| 9 |
{ |
| 10 |
int x; |
| 11 |
#ifdef _MSC_VER |
| 12 |
/*warning C4200: nonstandard extension used: zero-sized array in struct/union */ |
| 13 |
#pragma warning(disable:4200) |
| 14 |
#endif |
| 15 |
int flexible_array[]; |
| 16 |
} pos; |
| 17 |
|
| 18 |
DEFINE_REFCOUNT_TYPE(pos); |
| 19 |
|
| 20 |
POS_HANDLE Pos_Create(int x) |
| 21 |
{ |
| 22 |
pos* result = REFCOUNT_TYPE_CREATE(pos); |
| 23 |
if (result != NULL) |
| 24 |
{ |
| 25 |
result->x = x; |
| 26 |
} |
| 27 |
return result; |
| 28 |
} |
| 29 |
|
| 30 |
POS_HANDLE Pos_Create_With_Extra_Size(int x, size_t extra_size) |
| 31 |
{ |
| 32 |
pos* result = REFCOUNT_TYPE_CREATE_WITH_EXTRA_SIZE(pos, extra_size); |
| 33 |
if (result != NULL) |
| 34 |
{ |
| 35 |
result->x = x; |
| 36 |
} |
| 37 |
return result; |
| 38 |
} |
| 39 |
|
| 40 |
POS_HANDLE Pos_Clone(POS_HANDLE posHandle) |
| 41 |
{ |
| 42 |
|
| 43 |
if (posHandle != NULL) |
| 44 |
{ |
| 45 |
pos* p = posHandle; |
| 46 |
INC_REF(pos, p); |
| 47 |
} |
| 48 |
return posHandle; |
| 49 |
} |
| 50 |
|
| 51 |
void Pos_Destroy(POS_HANDLE posHandle) |
| 52 |
{ |
| 53 |
if (posHandle != NULL) |
| 54 |
{ |
| 55 |
pos* p = posHandle; |
| 56 |
if (DEC_REF(pos, p) == DEC_RETURN_ZERO) |
| 57 |
{ |
| 58 |
REFCOUNT_TYPE_DESTROY(pos, p); |
| 59 |
} |
| 60 |
} |
| 61 |
} |