MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / alloc_cstring

Function alloc_cstring

src/remote/protocol.cpp:1273–1316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1271
1272
1273static 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
1319void CSTRING::free(RemoteXdr* xdrs)

Callers 4

xdr_protocolFunction · 0.85
xdr_cstring_with_limitFunction · 0.85
xdr_longsFunction · 0.85
xdr_blob_streamFunction · 0.85

Calls 3

getDefaultMemoryPoolFunction · 0.85
DEBUG_XDR_ALLOCFunction · 0.70
freeMethod · 0.45

Tested by

no test coverage detected