Recent

Author Topic: Copy Bits  (Read 1652 times)

Gilles

  • New Member
  • *
  • Posts: 37
Copy Bits
« on: December 23, 2018, 09:56:12 am »
Hello

I would like copying bits from a CFMutableDataRef to another.
L_cnt bits starting in H_i at L_adi, to H_j starting in L_adj
That's how I perform this :


    procedure f_HBlockToHBlock (H_i, H_j: CFMutableDataRef; L_adi, L_adj, L_cnt: SInt32);
        var
            h_buf: CFMutableDataRef;
            h_xx_buf: UnivPtr;
    begin
        h_buf := CFDataCreateMutable(nil, L_cnt);

        if h_buf <> nil then
        begin
            h_xx_buf := CFDataGetMutableBytePtr(h_buf);

            CFDataGetBytes(H_i, CFRangeMake(L_adi, L_cnt), h_xx_buf);
            CFDataReplaceBytes(H_j, CFRangeMake(L_adj, L_cnt), h_xx_buf, L_cnt);

            CFRelease(h_buf)
        end
    end;


Well… I'm sure there is a simpler way (whithout having to create h-buf)
Any idea ?

G.
TurboPascal -> ThinkPascal -> CodeWarrior -> XCode with FPC -> (Well-deserved) Retirement (but not yet, not yet…)

 

TinyPortal © 2005-2018