| 1271 | |
| 1272 | |
| 1273 | static bool alloc_cstring(RemoteXdr* xdrs, CSTRING* cstring) |
| 1274 | { |
| 1275 | /************************************** |
| 1276 | * |
| 1277 | * a l l o c _ c s t r i n g |
| 1278 | * |
| 1279 | ************************************** |
| 1280 | * |
| 1281 | * Functional description |
| 1282 | * Handle allocation for cstring. |
| 1283 | * |
| 1284 | **************************************/ |
| 1285 | |
| 1286 | if (!cstring->cstr_length) |
| 1287 | { |
| 1288 | if (cstring->cstr_allocated) |
| 1289 | *cstring->cstr_address = '\0'; |
| 1290 | else |
| 1291 | cstring->cstr_address = NULL; |
| 1292 | |
| 1293 | return true; |
| 1294 | } |
| 1295 | |
| 1296 | if (cstring->cstr_length > cstring->cstr_allocated && cstring->cstr_allocated) |
| 1297 | { |
| 1298 | cstring->free(xdrs); |
| 1299 | } |
| 1300 | |
| 1301 | if (!cstring->cstr_address) |
| 1302 | { |
| 1303 | // fb_assert(!cstring->cstr_allocated); |
| 1304 | try { |
| 1305 | cstring->cstr_address = FB_NEW_POOL(*getDefaultMemoryPool()) UCHAR[cstring->cstr_length]; |
| 1306 | } |
| 1307 | catch (const BadAlloc&) { |
| 1308 | return false; |
| 1309 | } |
| 1310 | |
| 1311 | cstring->cstr_allocated = cstring->cstr_length; |
| 1312 | DEBUG_XDR_ALLOC(xdrs, cstring, cstring->cstr_address, cstring->cstr_allocated); |
| 1313 | } |
| 1314 | |
| 1315 | return true; |
| 1316 | } |
| 1317 | |
| 1318 | |
| 1319 | void CSTRING::free(RemoteXdr* xdrs) |
no test coverage detected