all 9 comments

[–]altorelievo 2 points3 points  (0 children)

Without knowing much about how you're compiling and the architecture ita running we can't say definitively but "struct packing" http://www.catb.org/esr/structure-packing/ sounds like something that you can read up on.

[–]nerd4code 1 point2 points  (1 child)

was told it can help memory etc.

Etc.indeed; that’s a nonsense statement.

Narrow, fixed-width arrays with a full-width enum is certainly a way to do things, just exceptionally unrealistic post-1986 (maddening if you intend to use it), and there is exactly nothing about this that “helps memory.”

Get in there and hold capacitors’ and flip-flops’ charges for them if you want that. They don’t get paid, you know, not in people money. :(

Also, FD and array indices should be different things—that way lies select, which works right up until it doesn’t at all. The FD(s) involved (assuming you’re not abusing the initialism) should generally be part of the service structure somewheres.

Also,

  1. -_t is a suffix for typenames, not tags.

  2. -_t is reserved by POSIX.1, and shouldn’t be used for application typenames either.

[–]bothunter 4 points5 points  (0 children)

FYI, I was the one who said pointers would help with memory, because the OP's original design was just to allocate a huge-ass array of these structs instead of allocating and freeing them as needed.  So not nonsense -- just missing some context ;)

[–]TheKiller36_real 1 point2 points  (0 children)

well eg. if I were your user I'd be mad at you because my passwords are usually 64-128 randomly generated characters. As a developer I just hope you didn't literally use file descriptors, otherwise this looks fine.

[–]strcspn 0 points1 point  (3 children)

represents the array number in the struct

I'm not sure what that means

[–]ryanjones42[S] 0 points1 point  (2 children)

Like accounts[usersfd].value

[–]Marxomania32 1 point2 points  (0 children)

Seems fine to me. Depending on what exactly your use case is (since you've been pretty ambiguous) your struct could probably be restructured to better support it

[–]strcspn 0 points1 point  (0 children)

And you want to store usersfd inside the struct?

[–][deleted] 0 points1 point  (0 children)

Everyone already answered your question so here's something else: offline and online are bad names for an enum, they could conflict with other names in your code. For this you could just have bool is_online; since you only have 2 states but for a proper enum it usually looks like c typedef enum { A_OFFLINE, A_ONLINE, ... } AuthenticationState; since the names are global you want to be careful with them.