| 407 | |
| 408 | |
| 409 | static bool_t xdr_slice(BurpXdr* xdrs, lstring* slice, /*USHORT sdl_length,*/ const UCHAR* sdl) |
| 410 | { |
| 411 | /************************************** |
| 412 | * |
| 413 | * x d r _ s l i c e |
| 414 | * |
| 415 | ************************************** |
| 416 | * |
| 417 | * Functional description |
| 418 | * Move a slice of an array under |
| 419 | * |
| 420 | **************************************/ |
| 421 | if (!xdr_long(xdrs, reinterpret_cast<SLONG*>(&slice->lstr_length))) |
| 422 | return FALSE; |
| 423 | |
| 424 | if ((xdrs->x_op != XDR_FREE) && !sdl) |
| 425 | return FALSE; |
| 426 | |
| 427 | // Handle operation specific stuff, particularly memory allocation/deallocation |
| 428 | |
| 429 | switch (xdrs->x_op) |
| 430 | { |
| 431 | case XDR_ENCODE: |
| 432 | break; |
| 433 | |
| 434 | case XDR_DECODE: |
| 435 | if (!slice->lstr_length) |
| 436 | return TRUE; |
| 437 | if (slice->lstr_length > slice->lstr_allocated && slice->lstr_allocated) |
| 438 | { |
| 439 | BURP_free(slice->lstr_address); |
| 440 | slice->lstr_address = NULL; |
| 441 | } |
| 442 | if (!slice->lstr_address) |
| 443 | { |
| 444 | slice->lstr_address = BURP_alloc((SLONG) slice->lstr_length); |
| 445 | if (!slice->lstr_address) { |
| 446 | return FALSE; |
| 447 | } |
| 448 | slice->lstr_allocated = slice->lstr_length; |
| 449 | } |
| 450 | break; |
| 451 | |
| 452 | case XDR_FREE: |
| 453 | if (slice->lstr_allocated) |
| 454 | BURP_free(slice->lstr_address); |
| 455 | slice->lstr_address = NULL; |
| 456 | slice->lstr_allocated = 0; |
| 457 | return TRUE; |
| 458 | |
| 459 | default: |
| 460 | fb_assert(FALSE); |
| 461 | return FALSE; |
| 462 | } |
| 463 | |
| 464 | // Get descriptor of array element |
| 465 | |
| 466 | sdl_info info; |