Reputation: 2239
I am reading REBOL source code and I can't understand the purpose of the following statement:
/***********************************************************************
**
*/ int main(int argc, char **argv)
/*
***********************************************************************/
{
char *cmd;
// Parse command line arguments. Done early. May affect REBOL boot.
Parse_Args(argc, argv, &Main_Args);
Print_Str("REBOL 3.0\n");
REBOL_Init(&Main_Args);
// Evaluate user input:
while (TRUE) {
cmd = Prompt_User();
REBOL_Do_String(cmd);
if (!IS_UNSET(DS_TOP)) {
//if (DSP > 0) {
if (!IS_ERROR(DS_TOP)) {
Prin("== ");
Print_Value(DS_TOP, 0, TRUE);
} else
Print_Value(DS_TOP, 0, FALSE);
//}
}
//DS_DROP; // result
}
return 0;
}
In Parse_Args function:
/***********************************************************************
**
*/ void Parse_Args(int argc, REBCHR **argv, REBARGS *rargs)
/*
** Parse REBOL's command line arguments, setting options
** and values in the provided args structure.
**
***********************************************************************/
{
REBCHR *arg;
REBCHR *args = 0; // holds trailing args
int flag;
int i;
CLEARS(rargs);
....
And CLEARS is defined:
#define CLEARS(m) memset((void*)(m), 0, sizeof(*m));
So my question is why memset
is being used here?
Upvotes: 0
Views: 1400
Reputation: 1
memset sets a block of memory to a given value. It is normally written in hand optimized assembly and is expected to be blindingly fast.
Upvotes: 0
Reputation: 46051
It looks like rargs
is some kind of struct containing options for the program. CLEARS()
and memset()
is used to fill that struct with zero values to initiate it.
Upvotes: 3