- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
/* TODO: make this into something smarter than a linked list */
typedef struct bunchOfInstances_t {
ncInstance * instance;
int count; /* only valid on first node */
struct bunchOfInstances_t * next;
} bunchOfInstances;
ncInstance * get_instance (bunchOfInstances **headp)
{
static bunchOfInstances * current = NULL;
/* advance static variable, wrapping to head if at the end */
if ( current == NULL ) current = * headp;
else current = current->next;
/* return the new value, if any */
if ( current == NULL ) return NULL;
else return current->instance;
}
Зачем лишний typedef? Не хватает обычного struct bunchOfInstances_t {....}?
В Си это нужно, чтобы писать просто "bunchOfInstances", а не "struct bunchOfInstances_t"
typedef String Path;
и далее:
Path Path.Combine(Path path1, Path path2);
и т. д.
Или например
typedef int size;
Чтобы чётко понимать, чтО имеешь перед глазами, а не какое-то бесполое "int". Своего рода наследование от примитивных типов, короче.
struct mystruct myvar;
return (*headp)?(*headp)->instance:NULL