-
Notifications
You must be signed in to change notification settings - Fork 970
Align types of i, n, and _ut_i #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,8 +33,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| #include "utarray.h" // for "UT_icd" | ||
|
|
||
| typedef struct { | ||
| unsigned i; /* index of next available slot; wraps at n */ | ||
| unsigned n; /* capacity */ | ||
| size_t i; /* index of next available slot; wraps at n */ | ||
| size_t n; /* capacity */ | ||
| unsigned char f; /* full */ | ||
| UT_icd icd; /* initializer, copy and destructor functions */ | ||
| char *d; /* n slots of size icd->sz */ | ||
|
|
@@ -50,12 +50,12 @@ typedef struct { | |
| #define utringbuffer_clear(a) do { \ | ||
| if ((a)->icd.dtor) { \ | ||
| if ((a)->f) { \ | ||
| unsigned _ut_i; \ | ||
| size_t _ut_i; \ | ||
| for (_ut_i = 0; _ut_i < (a)->n; ++_ut_i) { \ | ||
| (a)->icd.dtor(utringbuffer_eltptr(a, _ut_i)); \ | ||
| } \ | ||
| } else { \ | ||
| unsigned _ut_i; \ | ||
| size_t _ut_i; \ | ||
| for (_ut_i = 0; _ut_i < (a)->i; ++_ut_i) { \ | ||
| (a)->icd.dtor(utringbuffer_eltptr(a, _ut_i)); \ | ||
| } \ | ||
|
|
@@ -94,7 +94,7 @@ typedef struct { | |
|
|
||
| #define _utringbuffer_real_idx(a,j) ((a)->f ? ((j) + (a)->i) % (a)->n : (j)) | ||
| #define _utringbuffer_internalptr(a,j) ((void*)((a)->d + ((a)->icd.sz * (j)))) | ||
| #define utringbuffer_eltptr(a,j) ((0 <= (j) && (j) < utringbuffer_len(a)) ? _utringbuffer_internalptr(a,_utringbuffer_real_idx(a,j)) : NULL) | ||
| #define utringbuffer_eltptr(a,j) (((j) < utringbuffer_len(a)) ? _utringbuffer_internalptr(a,_utringbuffer_real_idx(a,j)) : NULL) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, here's the output from the compiler and seem to disagree with that assertion but it might be wrong. |
||
|
|
||
| #define _utringbuffer_fake_idx(a,j) ((a)->f ? ((j) + (a)->n - (a)->i) % (a)->n : (j)) | ||
| #define _utringbuffer_internalidx(a,e) (((char*)(e) >= (a)->d) ? (((char*)(e) - (a)->d)/(a)->icd.sz) : -1) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.