Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Activity for wasIzy
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Edit | Post #293502 | Initial revision | — | 27 days ago |
Answer | — |
A: 2D-array pointer as a struct member Yes, it is cheating, but I gave up with my question as originally stated, and settled for an x,y "view" in any function that must play with a given .items length by adding: ``` char (pixy)[len] = (char()[len]) baskets[len].items; ``` at the top of the functions concerned. With minimal time/sp... (more) |
— | 27 days ago |
Comment | Post #293256 |
Short break with grandchildren then a few days of messing around with this got me nowhere, so I have decided to settle for a simple compromise that actually works well for my use-case.
The bulk stays as before: struct member is `char *items` malloc-ed length * count and normal access is via "mangl... (more) |
— | 2 months ago |
Comment | Post #293256 |
Stand-alone 2D array on the heap and a pointer in `basket` ...doing that now!
Thanks for dragging me away from my obsession with squeezing a 2D declaration into the struct. (more) |
— | 3 months ago |
Comment | Post #293246 |
The data in the basket(s) is ALL from user-provided .txt files. The files are parsed, impossible data filtered out, and residual fed to the basket(s). From that moment (±0.02sec into the run) the basket(s) do not change: no edits; no realloc; NO flexibility.
"...accept that the data is stored else... (more) |
— | 3 months ago |
Comment | Post #293247 |
Thanks @celtschk for your suggestion: essentially a lookup-table into a (renamed) `char *items`. It would work, BUT Ignoring the inevitable memory inflation (237% in a simple test-case), the array-of-pointers look-up is not fast! Speed is a concern since the code must look (and re-look) millions of t... (more) |
— | 3 months ago |
Edit | Post #293246 |
Post edited: |
— | 3 months ago |
Comment | Post #293246 |
Data are values that fit comfortably in a char, NOT strings. They may match a "dictionary word" in some language, but are NEVER used in any string-like context (string.h, printf...%s, etc).
Execution speed is important: the code will access `baskets[]` millions of times in a run, how many millions... (more) |
— | 3 months ago |
Edit | Post #293246 | Initial revision | — | 3 months ago |
Question | — |
2D-array pointer as a struct member I have an array of struct: ``` static struct basket baskets[MAXITEMLEN + 1]; struct basket { char items; // malloc(itemlen itemcount) int itemcount; }; ``` `char items` does all I need to do with some pointer-gymnastics, but at times it gets a little ugly. I would prefer a 2D... (more) |
— | 3 months ago |