Results 1 to 2 of 2

Thread: doubt in c programming

  1. #1
    Join Date
    Oct 2007
    Posts
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Post doubt in c programming

    hi
    i have .c .h file.but i dont know how to call each funtion in main.c .i dont know for each funtion parameter what should i give.i have attached .c .h file with this.

    C Code:
    1. /* 7zBuffer.c */
    2.  
    3. #include "7zBuffer.h"
    4. #include "7zAlloc.h"
    5.  
    6. void SzByteBufferInit(CSzByteBuffer *buffer)
    7. {
    8. buffer->Capacity = 0;
    9. buffer->Items = 0;
    10. }
    11.  
    12. int SzByteBufferCreate(CSzByteBuffer *buffer, size_t newCapacity, void * (*allocFunc)(size_t size))
    13. {
    14. buffer->Capacity = newCapacity;
    15. if (newCapacity == 0)
    16. {
    17. buffer->Items = 0;
    18. return 1;
    19. }
    20. buffer->Items = (Byte *)allocFunc(newCapacity);
    21. return (buffer->Items != 0);
    22. }
    23.  
    24. void SzByteBufferFree(CSzByteBuffer *buffer, void (*freeFunc)(void *))
    25. {
    26. freeFunc(buffer->Items);
    27. buffer->Items = 0;
    28. buffer->Capacity = 0;
    29. }
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files
    Last edited by wysota; 9th November 2007 at 12:14. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: doubt in c programming

    What do you want to do? From what I see this is part of some API (7z compressor, probably). The three functions you pasted create, initialize and free the buffer.
    From what I see you may use it as follows:
    C Code:
    1. CSzByteBuffer buffer;
    2. SzByteBufferInit(&buffer);
    3. SzByteBufferCreate(&buffer, 10, malloc);
    4. /* ... */
    5. SzByteBufferFree(&buffer, free);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Doubt ?
    By Cutey in forum Qt Tools
    Replies: 2
    Last Post: 3rd March 2007, 10:45
  2. QT COM Programming
    By sarav in forum Newbie
    Replies: 5
    Last Post: 24th February 2007, 14:41
  3. Using QGraphicsView with model/view programming
    By JLP in forum Qt Programming
    Replies: 3
    Last Post: 29th January 2007, 12:04
  4. Model - View Programming doubt.
    By munna in forum Qt Programming
    Replies: 4
    Last Post: 28th April 2006, 14:01
  5. MODEL/VIEW programming
    By mira in forum Newbie
    Replies: 3
    Last Post: 21st April 2006, 12:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.