Strong Exception Guarantee
| 198 | |
| 199 | // Strong Exception Guarantee |
| 200 | af_err af_get_data_ref_count(int *use_count, const af_array in) { |
| 201 | try { |
| 202 | const ArrayInfo &info = getInfo(in, false); |
| 203 | const af_dtype type = info.getType(); |
| 204 | |
| 205 | int res; |
| 206 | switch (type) { |
| 207 | case f32: res = getUseCount<float>(in); break; |
| 208 | case c32: res = getUseCount<cfloat>(in); break; |
| 209 | case f64: res = getUseCount<double>(in); break; |
| 210 | case c64: res = getUseCount<cdouble>(in); break; |
| 211 | case b8: res = getUseCount<char>(in); break; |
| 212 | case s32: res = getUseCount<int>(in); break; |
| 213 | case u32: res = getUseCount<uint>(in); break; |
| 214 | case s8: res = getUseCount<schar>(in); break; |
| 215 | case u8: res = getUseCount<uchar>(in); break; |
| 216 | case s64: res = getUseCount<intl>(in); break; |
| 217 | case u64: res = getUseCount<uintl>(in); break; |
| 218 | case s16: res = getUseCount<short>(in); break; |
| 219 | case u16: res = getUseCount<ushort>(in); break; |
| 220 | case f16: res = getUseCount<half>(in); break; |
| 221 | default: TYPE_ERROR(1, type); |
| 222 | } |
| 223 | std::swap(*use_count, res); |
| 224 | } |
| 225 | CATCHALL |
| 226 | return AF_SUCCESS; |
| 227 | } |
| 228 | |
| 229 | af_err af_release_array(af_array arr) { |
| 230 | try { |