hexsha
stringlengths 40
40
| repo
stringlengths 5
105
| path
stringlengths 3
173
| license
sequence | language
stringclasses 1
value | identifier
stringlengths 1
438
| return_type
stringlengths 1
106
⌀ | original_string
stringlengths 21
40.7k
| original_docstring
stringlengths 18
13.4k
| docstring
stringlengths 11
3.24k
| docstring_tokens
sequence | code
stringlengths 14
20.4k
| code_tokens
sequence | short_docstring
stringlengths 0
4.36k
| short_docstring_tokens
sequence | comment
sequence | parameters
list | docstring_params
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bce6b51fd1c86f9870bd33f43771a8509ca895c9 | mischcon/Clustering | src/main/resources/gems/debase-0.2.2.beta9/ext/debase_internals.c | [
"Apache-2.0"
] | C | Debase_verbose | VALUE | static VALUE
Debase_verbose(VALUE self)
{
return verbose;
} | /*
* call-seq:
* Debase.verbose? -> bool
*
* Returns +true+ if verbose output of TracePoint API events is enabled.
*/ |
Returns +true+ if verbose output of TracePoint API events is enabled. | [
"Returns",
"+",
"true",
"+",
"if",
"verbose",
"output",
"of",
"TracePoint",
"API",
"events",
"is",
"enabled",
"."
] | static VALUE
Debase_verbose(VALUE self)
{
return verbose;
} | [
"static",
"VALUE",
"Debase_verbose",
"(",
"VALUE",
"self",
")",
"{",
"return",
"verbose",
";",
"}"
] | call-seq:
Debase.verbose? | [
"call",
"-",
"seq",
":",
"Debase",
".",
"verbose?"
] | [] | [
{
"param": "self",
"type": "VALUE"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": "VALUE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
bce6b51fd1c86f9870bd33f43771a8509ca895c9 | mischcon/Clustering | src/main/resources/gems/debase-0.2.2.beta9/ext/debase_internals.c | [
"Apache-2.0"
] | C | Debase_set_verbose | VALUE | static VALUE
Debase_set_verbose(VALUE self, VALUE value)
{
verbose = RTEST(value) ? Qtrue : Qfalse;
return value;
} | /*
* call-seq:
* Debase.verbose = bool
*
* Enable verbose output of every TracePoint API events, useful for debugging debase.
*/ |
Enable verbose output of every TracePoint API events, useful for debugging debase. | [
"Enable",
"verbose",
"output",
"of",
"every",
"TracePoint",
"API",
"events",
"useful",
"for",
"debugging",
"debase",
"."
] | static VALUE
Debase_set_verbose(VALUE self, VALUE value)
{
verbose = RTEST(value) ? Qtrue : Qfalse;
return value;
} | [
"static",
"VALUE",
"Debase_set_verbose",
"(",
"VALUE",
"self",
",",
"VALUE",
"value",
")",
"{",
"verbose",
"=",
"RTEST",
"(",
"value",
")",
"?",
"Qtrue",
":",
"Qfalse",
";",
"return",
"value",
";",
"}"
] | call-seq:
Debase.verbose = bool | [
"call",
"-",
"seq",
":",
"Debase",
".",
"verbose",
"=",
"bool"
] | [] | [
{
"param": "self",
"type": "VALUE"
},
{
"param": "value",
"type": "VALUE"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": "VALUE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": "VALUE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
bce6b51fd1c86f9870bd33f43771a8509ca895c9 | mischcon/Clustering | src/main/resources/gems/debase-0.2.2.beta9/ext/debase_internals.c | [
"Apache-2.0"
] | C | Init_debase_internals | void | void
Init_debase_internals()
{
mDebase = rb_define_module("Debase");
rb_define_module_function(mDebase, "setup_tracepoints", Debase_setup_tracepoints, 0);
rb_define_module_function(mDebase, "remove_tracepoints", Debase_remove_tracepoints, 0);
rb_define_module_function(mDebase, "current_context", Debase_current_context, 0);
rb_define_module_function(mDebase, "debug_load", Debase_debug_load, -1);
rb_define_module_function(mDebase, "contexts", Debase_contexts, 0);
rb_define_module_function(mDebase, "breakpoints", Debase_breakpoints, 0);
rb_define_module_function(mDebase, "catchpoints", Debase_catchpoints, 0);
rb_define_module_function(mDebase, "started?", Debase_started, 0);
rb_define_module_function(mDebase, "verbose?", Debase_verbose, 0);
rb_define_module_function(mDebase, "verbose=", Debase_set_verbose, 1);
rb_define_module_function(mDebase, "enable_file_filtering", Debase_enable_file_filtering, 1);
rb_define_module_function(mDebase, "enable_trace_points", Debase_enable_trace_points, 0);
rb_define_module_function(mDebase, "prepare_context", Debase_prepare_context, 0);
rb_define_module_function(mDebase, "init_variables", Debase_init_variables, 0);
idAlive = rb_intern("alive?");
idAtLine = rb_intern("at_line");
idAtBreakpoint = rb_intern("at_breakpoint");
idAtCatchpoint = rb_intern("at_catchpoint");
idFileFilter = rb_intern("file_filter");
idAccept = rb_intern("accept?");
cContext = Init_context(mDebase);
Init_breakpoint(mDebase);
cDebugThread = rb_define_class_under(mDebase, "DebugThread", rb_cThread);
Debase_init_variables();
rb_global_variable(&locker);
rb_global_variable(&breakpoints);
rb_global_variable(&catchpoints);
rb_global_variable(&contexts);
} | /*
* Document-class: Debase
*
* == Summary
*
* This is a singleton class allows controlling the debugger. Use it to start/stop debugger,
* set/remove breakpoints, etc.
*/ | Document-class: Debase
== Summary
This is a singleton class allows controlling the debugger. Use it to start/stop debugger,
set/remove breakpoints, etc. | [
"Document",
"-",
"class",
":",
"Debase",
"==",
"Summary",
"This",
"is",
"a",
"singleton",
"class",
"allows",
"controlling",
"the",
"debugger",
".",
"Use",
"it",
"to",
"start",
"/",
"stop",
"debugger",
"set",
"/",
"remove",
"breakpoints",
"etc",
"."
] | void
Init_debase_internals()
{
mDebase = rb_define_module("Debase");
rb_define_module_function(mDebase, "setup_tracepoints", Debase_setup_tracepoints, 0);
rb_define_module_function(mDebase, "remove_tracepoints", Debase_remove_tracepoints, 0);
rb_define_module_function(mDebase, "current_context", Debase_current_context, 0);
rb_define_module_function(mDebase, "debug_load", Debase_debug_load, -1);
rb_define_module_function(mDebase, "contexts", Debase_contexts, 0);
rb_define_module_function(mDebase, "breakpoints", Debase_breakpoints, 0);
rb_define_module_function(mDebase, "catchpoints", Debase_catchpoints, 0);
rb_define_module_function(mDebase, "started?", Debase_started, 0);
rb_define_module_function(mDebase, "verbose?", Debase_verbose, 0);
rb_define_module_function(mDebase, "verbose=", Debase_set_verbose, 1);
rb_define_module_function(mDebase, "enable_file_filtering", Debase_enable_file_filtering, 1);
rb_define_module_function(mDebase, "enable_trace_points", Debase_enable_trace_points, 0);
rb_define_module_function(mDebase, "prepare_context", Debase_prepare_context, 0);
rb_define_module_function(mDebase, "init_variables", Debase_init_variables, 0);
idAlive = rb_intern("alive?");
idAtLine = rb_intern("at_line");
idAtBreakpoint = rb_intern("at_breakpoint");
idAtCatchpoint = rb_intern("at_catchpoint");
idFileFilter = rb_intern("file_filter");
idAccept = rb_intern("accept?");
cContext = Init_context(mDebase);
Init_breakpoint(mDebase);
cDebugThread = rb_define_class_under(mDebase, "DebugThread", rb_cThread);
Debase_init_variables();
rb_global_variable(&locker);
rb_global_variable(&breakpoints);
rb_global_variable(&catchpoints);
rb_global_variable(&contexts);
} | [
"void",
"Init_debase_internals",
"(",
")",
"{",
"mDebase",
"=",
"rb_define_module",
"(",
"\"",
"\"",
")",
";",
"rb_define_module_function",
"(",
"mDebase",
",",
"\"",
"\"",
",",
"Debase_setup_tracepoints",
",",
"0",
")",
";",
"rb_define_module_function",
"(",
"mDebase",
",",
"\"",
"\"",
",",
"Debase_remove_tracepoints",
",",
"0",
")",
";",
"rb_define_module_function",
"(",
"mDebase",
",",
"\"",
"\"",
",",
"Debase_current_context",
",",
"0",
")",
";",
"rb_define_module_function",
"(",
"mDebase",
",",
"\"",
"\"",
",",
"Debase_debug_load",
",",
"-1",
")",
";",
"rb_define_module_function",
"(",
"mDebase",
",",
"\"",
"\"",
",",
"Debase_contexts",
",",
"0",
")",
";",
"rb_define_module_function",
"(",
"mDebase",
",",
"\"",
"\"",
",",
"Debase_breakpoints",
",",
"0",
")",
";",
"rb_define_module_function",
"(",
"mDebase",
",",
"\"",
"\"",
",",
"Debase_catchpoints",
",",
"0",
")",
";",
"rb_define_module_function",
"(",
"mDebase",
",",
"\"",
"\"",
",",
"Debase_started",
",",
"0",
")",
";",
"rb_define_module_function",
"(",
"mDebase",
",",
"\"",
"\"",
",",
"Debase_verbose",
",",
"0",
")",
";",
"rb_define_module_function",
"(",
"mDebase",
",",
"\"",
"\"",
",",
"Debase_set_verbose",
",",
"1",
")",
";",
"rb_define_module_function",
"(",
"mDebase",
",",
"\"",
"\"",
",",
"Debase_enable_file_filtering",
",",
"1",
")",
";",
"rb_define_module_function",
"(",
"mDebase",
",",
"\"",
"\"",
",",
"Debase_enable_trace_points",
",",
"0",
")",
";",
"rb_define_module_function",
"(",
"mDebase",
",",
"\"",
"\"",
",",
"Debase_prepare_context",
",",
"0",
")",
";",
"rb_define_module_function",
"(",
"mDebase",
",",
"\"",
"\"",
",",
"Debase_init_variables",
",",
"0",
")",
";",
"idAlive",
"=",
"rb_intern",
"(",
"\"",
"\"",
")",
";",
"idAtLine",
"=",
"rb_intern",
"(",
"\"",
"\"",
")",
";",
"idAtBreakpoint",
"=",
"rb_intern",
"(",
"\"",
"\"",
")",
";",
"idAtCatchpoint",
"=",
"rb_intern",
"(",
"\"",
"\"",
")",
";",
"idFileFilter",
"=",
"rb_intern",
"(",
"\"",
"\"",
")",
";",
"idAccept",
"=",
"rb_intern",
"(",
"\"",
"\"",
")",
";",
"cContext",
"=",
"Init_context",
"(",
"mDebase",
")",
";",
"Init_breakpoint",
"(",
"mDebase",
")",
";",
"cDebugThread",
"=",
"rb_define_class_under",
"(",
"mDebase",
",",
"\"",
"\"",
",",
"rb_cThread",
")",
";",
"Debase_init_variables",
"(",
")",
";",
"rb_global_variable",
"(",
"&",
"locker",
")",
";",
"rb_global_variable",
"(",
"&",
"breakpoints",
")",
";",
"rb_global_variable",
"(",
"&",
"catchpoints",
")",
";",
"rb_global_variable",
"(",
"&",
"contexts",
")",
";",
"}"
] | Document-class: Debase
== Summary | [
"Document",
"-",
"class",
":",
"Debase",
"==",
"Summary"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
6d497b0df1576e214145eed8902bfeaf4dd65440 | vsvld/rmagick | ext/RMagick/rmkinfo.c | [
"MIT"
] | C | rm_kernel_info_destroy | void | static void
rm_kernel_info_destroy(void *kernel)
{
if (kernel)
DestroyKernelInfo((KernelInfo*)kernel);
} | /**
* If there's a kernel info, delete it before destroying the KernelInfo
*
* No Ruby usage (internal function)
*
* @param kernel pointer to the KernelInfo object associated with instance
*/ | If there's a kernel info, delete it before destroying the KernelInfo
No Ruby usage (internal function)
@param kernel pointer to the KernelInfo object associated with instance | [
"If",
"there",
"'",
"s",
"a",
"kernel",
"info",
"delete",
"it",
"before",
"destroying",
"the",
"KernelInfo",
"No",
"Ruby",
"usage",
"(",
"internal",
"function",
")",
"@param",
"kernel",
"pointer",
"to",
"the",
"KernelInfo",
"object",
"associated",
"with",
"instance"
] | static void
rm_kernel_info_destroy(void *kernel)
{
if (kernel)
DestroyKernelInfo((KernelInfo*)kernel);
} | [
"static",
"void",
"rm_kernel_info_destroy",
"(",
"void",
"*",
"kernel",
")",
"{",
"if",
"(",
"kernel",
")",
"DestroyKernelInfo",
"(",
"(",
"KernelInfo",
"*",
")",
"kernel",
")",
";",
"}"
] | If there's a kernel info, delete it before destroying the KernelInfo
No Ruby usage (internal function) | [
"If",
"there",
"'",
"s",
"a",
"kernel",
"info",
"delete",
"it",
"before",
"destroying",
"the",
"KernelInfo",
"No",
"Ruby",
"usage",
"(",
"internal",
"function",
")"
] | [] | [
{
"param": "kernel",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "kernel",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6d497b0df1576e214145eed8902bfeaf4dd65440 | vsvld/rmagick | ext/RMagick/rmkinfo.c | [
"MIT"
] | C | KernelInfo_alloc | VALUE | VALUE
KernelInfo_alloc(VALUE class)
{
return Data_Wrap_Struct(class, NULL, rm_kernel_info_destroy, NULL);
} | /**
* Create a KernelInfo object.
*
* No Ruby usage (internal function)
*
* @param class the Ruby class to use
* @return a new KernelInfo object
*/ | Create a KernelInfo object.
No Ruby usage (internal function)
@param class the Ruby class to use
@return a new KernelInfo object | [
"Create",
"a",
"KernelInfo",
"object",
".",
"No",
"Ruby",
"usage",
"(",
"internal",
"function",
")",
"@param",
"class",
"the",
"Ruby",
"class",
"to",
"use",
"@return",
"a",
"new",
"KernelInfo",
"object"
] | VALUE
KernelInfo_alloc(VALUE class)
{
return Data_Wrap_Struct(class, NULL, rm_kernel_info_destroy, NULL);
} | [
"VALUE",
"KernelInfo_alloc",
"(",
"VALUE",
"class",
")",
"{",
"return",
"Data_Wrap_Struct",
"(",
"class",
",",
"NULL",
",",
"rm_kernel_info_destroy",
",",
"NULL",
")",
";",
"}"
] | Create a KernelInfo object. | [
"Create",
"a",
"KernelInfo",
"object",
"."
] | [] | [
{
"param": "class",
"type": "VALUE"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "class",
"type": "VALUE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6d497b0df1576e214145eed8902bfeaf4dd65440 | vsvld/rmagick | ext/RMagick/rmkinfo.c | [
"MIT"
] | C | KernelInfo_initialize | VALUE | VALUE
KernelInfo_initialize(VALUE self, VALUE kernel_string)
{
KernelInfo *kernel;
#if defined(IMAGEMAGICK_7)
ExceptionInfo *exception;
#endif
Check_Type(kernel_string, T_STRING);
#if defined(IMAGEMAGICK_7)
exception = AcquireExceptionInfo();
kernel = AcquireKernelInfo(StringValueCStr(kernel_string), exception);
if (rm_should_raise_exception(exception, DestroyExceptionRetention))
{
if (kernel != (KernelInfo *) NULL)
{
(void) DestroyKernelInfo(kernel);
}
rm_raise_exception(exception);
}
#else
kernel = AcquireKernelInfo(StringValueCStr(kernel_string));
#endif
if (!kernel)
{
rb_raise(rb_eRuntimeError, "failed to parse kernel string");
}
DATA_PTR(self) = kernel;
return self;
} | /**
* KernelInfo object constructor
*
* Ruby usage:
* - @verbatim KernelInfo#initialize @endverbatim
*
* @param self this object
* @param kernel_string kernel info string representation to be parsed
* @return self
*/ | KernelInfo object constructor
Ruby usage:
- @verbatim KernelInfo#initialize @endverbatim
@param self this object
@param kernel_string kernel info string representation to be parsed
@return self | [
"KernelInfo",
"object",
"constructor",
"Ruby",
"usage",
":",
"-",
"@verbatim",
"KernelInfo#initialize",
"@endverbatim",
"@param",
"self",
"this",
"object",
"@param",
"kernel_string",
"kernel",
"info",
"string",
"representation",
"to",
"be",
"parsed",
"@return",
"self"
] | VALUE
KernelInfo_initialize(VALUE self, VALUE kernel_string)
{
KernelInfo *kernel;
#if defined(IMAGEMAGICK_7)
ExceptionInfo *exception;
#endif
Check_Type(kernel_string, T_STRING);
#if defined(IMAGEMAGICK_7)
exception = AcquireExceptionInfo();
kernel = AcquireKernelInfo(StringValueCStr(kernel_string), exception);
if (rm_should_raise_exception(exception, DestroyExceptionRetention))
{
if (kernel != (KernelInfo *) NULL)
{
(void) DestroyKernelInfo(kernel);
}
rm_raise_exception(exception);
}
#else
kernel = AcquireKernelInfo(StringValueCStr(kernel_string));
#endif
if (!kernel)
{
rb_raise(rb_eRuntimeError, "failed to parse kernel string");
}
DATA_PTR(self) = kernel;
return self;
} | [
"VALUE",
"KernelInfo_initialize",
"(",
"VALUE",
"self",
",",
"VALUE",
"kernel_string",
")",
"{",
"KernelInfo",
"*",
"kernel",
";",
"#if",
"defined",
"(",
"IMAGEMAGICK_7",
")",
"\n",
"ExceptionInfo",
"*",
"exception",
";",
"#endif",
"Check_Type",
"(",
"kernel_string",
",",
"T_STRING",
")",
";",
"#if",
"defined",
"(",
"IMAGEMAGICK_7",
")",
"\n",
"exception",
"=",
"AcquireExceptionInfo",
"(",
")",
";",
"kernel",
"=",
"AcquireKernelInfo",
"(",
"StringValueCStr",
"(",
"kernel_string",
")",
",",
"exception",
")",
";",
"if",
"(",
"rm_should_raise_exception",
"(",
"exception",
",",
"DestroyExceptionRetention",
")",
")",
"{",
"if",
"(",
"kernel",
"!=",
"(",
"KernelInfo",
"*",
")",
"NULL",
")",
"{",
"(",
"void",
")",
"DestroyKernelInfo",
"(",
"kernel",
")",
";",
"}",
"rm_raise_exception",
"(",
"exception",
")",
";",
"}",
"#else",
"kernel",
"=",
"AcquireKernelInfo",
"(",
"StringValueCStr",
"(",
"kernel_string",
")",
")",
";",
"#endif",
"if",
"(",
"!",
"kernel",
")",
"{",
"rb_raise",
"(",
"rb_eRuntimeError",
",",
"\"",
"\"",
")",
";",
"}",
"DATA_PTR",
"(",
"self",
")",
"=",
"kernel",
";",
"return",
"self",
";",
"}"
] | KernelInfo object constructor
Ruby usage:
- @verbatim KernelInfo#initialize @endverbatim | [
"KernelInfo",
"object",
"constructor",
"Ruby",
"usage",
":",
"-",
"@verbatim",
"KernelInfo#initialize",
"@endverbatim"
] | [] | [
{
"param": "self",
"type": "VALUE"
},
{
"param": "kernel_string",
"type": "VALUE"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": "VALUE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "kernel_string",
"type": "VALUE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6d497b0df1576e214145eed8902bfeaf4dd65440 | vsvld/rmagick | ext/RMagick/rmkinfo.c | [
"MIT"
] | C | KernelInfo_scale_geometry | VALUE | VALUE
KernelInfo_scale_geometry(VALUE self, VALUE geometry)
{
Check_Type(geometry, T_STRING);
ScaleGeometryKernelInfo((KernelInfo*)DATA_PTR(self), StringValueCStr(geometry));
return Qnil;
} | /**
* Takes a geometry argument string, typically provided as a "-set option:convolve:scale {geometry}" user setting,
* and modifies the kernel according to the parsed arguments of that setting.
*
* Ruby usage:
* - @verbatim KernelInfo#scale_geometry(geometry) @endverbatim
*
* @param geometry geometry string to parse and apply
* @param self this object
*/ | Takes a geometry argument string, typically provided as a "-set option:convolve:scale {geometry}" user setting,
and modifies the kernel according to the parsed arguments of that setting.
@param geometry geometry string to parse and apply
@param self this object | [
"Takes",
"a",
"geometry",
"argument",
"string",
"typically",
"provided",
"as",
"a",
"\"",
"-",
"set",
"option",
":",
"convolve",
":",
"scale",
"{",
"geometry",
"}",
"\"",
"user",
"setting",
"and",
"modifies",
"the",
"kernel",
"according",
"to",
"the",
"parsed",
"arguments",
"of",
"that",
"setting",
".",
"@param",
"geometry",
"geometry",
"string",
"to",
"parse",
"and",
"apply",
"@param",
"self",
"this",
"object"
] | VALUE
KernelInfo_scale_geometry(VALUE self, VALUE geometry)
{
Check_Type(geometry, T_STRING);
ScaleGeometryKernelInfo((KernelInfo*)DATA_PTR(self), StringValueCStr(geometry));
return Qnil;
} | [
"VALUE",
"KernelInfo_scale_geometry",
"(",
"VALUE",
"self",
",",
"VALUE",
"geometry",
")",
"{",
"Check_Type",
"(",
"geometry",
",",
"T_STRING",
")",
";",
"ScaleGeometryKernelInfo",
"(",
"(",
"KernelInfo",
"*",
")",
"DATA_PTR",
"(",
"self",
")",
",",
"StringValueCStr",
"(",
"geometry",
")",
")",
";",
"return",
"Qnil",
";",
"}"
] | Takes a geometry argument string, typically provided as a "-set option:convolve:scale {geometry}" user setting,
and modifies the kernel according to the parsed arguments of that setting. | [
"Takes",
"a",
"geometry",
"argument",
"string",
"typically",
"provided",
"as",
"a",
"\"",
"-",
"set",
"option",
":",
"convolve",
":",
"scale",
"{",
"geometry",
"}",
"\"",
"user",
"setting",
"and",
"modifies",
"the",
"kernel",
"according",
"to",
"the",
"parsed",
"arguments",
"of",
"that",
"setting",
"."
] | [] | [
{
"param": "self",
"type": "VALUE"
},
{
"param": "geometry",
"type": "VALUE"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": "VALUE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "geometry",
"type": "VALUE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6d497b0df1576e214145eed8902bfeaf4dd65440 | vsvld/rmagick | ext/RMagick/rmkinfo.c | [
"MIT"
] | C | KernelInfo_clone | VALUE | VALUE
KernelInfo_clone(VALUE self)
{
KernelInfo *kernel = CloneKernelInfo((KernelInfo*)DATA_PTR(self));
return Data_Wrap_Struct(Class_KernelInfo, NULL, rm_kernel_info_destroy, kernel);
} | /**
* Creates a new clone of the object so that its can be modified without effecting the original.
*
* Ruby usage:
* - @verbatim KernelInfo#clone @endverbatim
*
* @param self this object
* @return new KernelInfo instance
*/ | Creates a new clone of the object so that its can be modified without effecting the original.
Ruby usage:
- @verbatim KernelInfo#clone @endverbatim
@param self this object
@return new KernelInfo instance | [
"Creates",
"a",
"new",
"clone",
"of",
"the",
"object",
"so",
"that",
"its",
"can",
"be",
"modified",
"without",
"effecting",
"the",
"original",
".",
"Ruby",
"usage",
":",
"-",
"@verbatim",
"KernelInfo#clone",
"@endverbatim",
"@param",
"self",
"this",
"object",
"@return",
"new",
"KernelInfo",
"instance"
] | VALUE
KernelInfo_clone(VALUE self)
{
KernelInfo *kernel = CloneKernelInfo((KernelInfo*)DATA_PTR(self));
return Data_Wrap_Struct(Class_KernelInfo, NULL, rm_kernel_info_destroy, kernel);
} | [
"VALUE",
"KernelInfo_clone",
"(",
"VALUE",
"self",
")",
"{",
"KernelInfo",
"*",
"kernel",
"=",
"CloneKernelInfo",
"(",
"(",
"KernelInfo",
"*",
")",
"DATA_PTR",
"(",
"self",
")",
")",
";",
"return",
"Data_Wrap_Struct",
"(",
"Class_KernelInfo",
",",
"NULL",
",",
"rm_kernel_info_destroy",
",",
"kernel",
")",
";",
"}"
] | Creates a new clone of the object so that its can be modified without effecting the original. | [
"Creates",
"a",
"new",
"clone",
"of",
"the",
"object",
"so",
"that",
"its",
"can",
"be",
"modified",
"without",
"effecting",
"the",
"original",
"."
] | [] | [
{
"param": "self",
"type": "VALUE"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": "VALUE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6d497b0df1576e214145eed8902bfeaf4dd65440 | vsvld/rmagick | ext/RMagick/rmkinfo.c | [
"MIT"
] | C | KernelInfo_builtin | VALUE | VALUE
KernelInfo_builtin(VALUE self, VALUE what, VALUE geometry)
{
KernelInfo *kernel;
KernelInfoType kernel_type;
GeometryInfo info;
#if defined(IMAGEMAGICK_7)
ExceptionInfo *exception;
#endif
Check_Type(geometry, T_STRING);
VALUE_TO_ENUM(what, kernel_type, KernelInfoType);
ParseGeometry(StringValueCStr(geometry), &info);
#if defined(IMAGEMAGICK_7)
exception = AcquireExceptionInfo();
kernel = AcquireKernelBuiltIn(kernel_type, &info, exception);
if (rm_should_raise_exception(exception, DestroyExceptionRetention))
{
if (kernel != (KernelInfo *) NULL)
{
(void) DestroyKernelInfo(kernel);
}
rm_raise_exception(exception);
}
#else
kernel = AcquireKernelBuiltIn(kernel_type, &info);
#endif
if (!kernel)
{
rb_raise(rb_eRuntimeError, "failed to acquire builtin kernel");
}
return Data_Wrap_Struct(self, NULL, rm_kernel_info_destroy, kernel);
} | /**
* Create new instance of KernelInfo with one of the 'named' built-in types of
* kernels used for special purposes such as gaussian blurring, skeleton
* pruning, and edge distance determination.
*
* Ruby usage:
* - @verbatim KernelInfo.builtin(kernel, geometry = nil) @endverbatim
*
* @parms kernel one of Magick::KernelInfoType enums:
* Magick::UndefinedKernel
* Magick::UnityKernel
* Magick::GaussianKernel
* Magick::DoGKernel
* Magick::LoGKernel
* Magick::BlurKernel
* Magick::CometKernel
* Magick::LaplacianKernel
* Magick::SobelKernel
* Magick::FreiChenKernel
* Magick::RobertsKernel
* Magick::PrewittKernel
* Magick::CompassKernel
* Magick::KirschKernel
* Magick::DiamondKernel
* Magick::SquareKernel
* Magick::RectangleKernel
* Magick::OctagonKernel
* Magick::DiskKernel
* Magick::PlusKernel
* Magick::CrossKernel
* Magick::RingKernel
* Magick::PeaksKernel
* Magick::EdgesKernel
* Magick::CornersKernel
* Magick::DiagonalsKernel
* Magick::LineEndsKernel
* Magick::LineJunctionsKernel
* Magick::RidgesKernel
* Magick::ConvexHullKernel
* Magick::ThinSEKernel
* Magick::SkeletonKernel
* Magick::ChebyshevKernel
* Magick::ManhattanKernel
* Magick::OctagonalKernel
* Magick::EuclideanKernel
* Magick::UserDefinedKernel
* Magick::BinomialKernel
* @param geometry geometry to pass to default kernel
* @return KernelInfo instance
*/ | Create new instance of KernelInfo with one of the 'named' built-in types of
kernels used for special purposes such as gaussian blurring, skeleton
pruning, and edge distance determination.
Ruby usage:
- @verbatim KernelInfo.builtin(kernel, geometry = nil) @endverbatim
| [
"Create",
"new",
"instance",
"of",
"KernelInfo",
"with",
"one",
"of",
"the",
"'",
"named",
"'",
"built",
"-",
"in",
"types",
"of",
"kernels",
"used",
"for",
"special",
"purposes",
"such",
"as",
"gaussian",
"blurring",
"skeleton",
"pruning",
"and",
"edge",
"distance",
"determination",
".",
"Ruby",
"usage",
":",
"-",
"@verbatim",
"KernelInfo",
".",
"builtin",
"(",
"kernel",
"geometry",
"=",
"nil",
")",
"@endverbatim"
] | VALUE
KernelInfo_builtin(VALUE self, VALUE what, VALUE geometry)
{
KernelInfo *kernel;
KernelInfoType kernel_type;
GeometryInfo info;
#if defined(IMAGEMAGICK_7)
ExceptionInfo *exception;
#endif
Check_Type(geometry, T_STRING);
VALUE_TO_ENUM(what, kernel_type, KernelInfoType);
ParseGeometry(StringValueCStr(geometry), &info);
#if defined(IMAGEMAGICK_7)
exception = AcquireExceptionInfo();
kernel = AcquireKernelBuiltIn(kernel_type, &info, exception);
if (rm_should_raise_exception(exception, DestroyExceptionRetention))
{
if (kernel != (KernelInfo *) NULL)
{
(void) DestroyKernelInfo(kernel);
}
rm_raise_exception(exception);
}
#else
kernel = AcquireKernelBuiltIn(kernel_type, &info);
#endif
if (!kernel)
{
rb_raise(rb_eRuntimeError, "failed to acquire builtin kernel");
}
return Data_Wrap_Struct(self, NULL, rm_kernel_info_destroy, kernel);
} | [
"VALUE",
"KernelInfo_builtin",
"(",
"VALUE",
"self",
",",
"VALUE",
"what",
",",
"VALUE",
"geometry",
")",
"{",
"KernelInfo",
"*",
"kernel",
";",
"KernelInfoType",
"kernel_type",
";",
"GeometryInfo",
"info",
";",
"#if",
"defined",
"(",
"IMAGEMAGICK_7",
")",
"\n",
"ExceptionInfo",
"*",
"exception",
";",
"#endif",
"Check_Type",
"(",
"geometry",
",",
"T_STRING",
")",
";",
"VALUE_TO_ENUM",
"(",
"what",
",",
"kernel_type",
",",
"KernelInfoType",
")",
";",
"ParseGeometry",
"(",
"StringValueCStr",
"(",
"geometry",
")",
",",
"&",
"info",
")",
";",
"#if",
"defined",
"(",
"IMAGEMAGICK_7",
")",
"\n",
"exception",
"=",
"AcquireExceptionInfo",
"(",
")",
";",
"kernel",
"=",
"AcquireKernelBuiltIn",
"(",
"kernel_type",
",",
"&",
"info",
",",
"exception",
")",
";",
"if",
"(",
"rm_should_raise_exception",
"(",
"exception",
",",
"DestroyExceptionRetention",
")",
")",
"{",
"if",
"(",
"kernel",
"!=",
"(",
"KernelInfo",
"*",
")",
"NULL",
")",
"{",
"(",
"void",
")",
"DestroyKernelInfo",
"(",
"kernel",
")",
";",
"}",
"rm_raise_exception",
"(",
"exception",
")",
";",
"}",
"#else",
"kernel",
"=",
"AcquireKernelBuiltIn",
"(",
"kernel_type",
",",
"&",
"info",
")",
";",
"#endif",
"if",
"(",
"!",
"kernel",
")",
"{",
"rb_raise",
"(",
"rb_eRuntimeError",
",",
"\"",
"\"",
")",
";",
"}",
"return",
"Data_Wrap_Struct",
"(",
"self",
",",
"NULL",
",",
"rm_kernel_info_destroy",
",",
"kernel",
")",
";",
"}"
] | Create new instance of KernelInfo with one of the 'named' built-in types of
kernels used for special purposes such as gaussian blurring, skeleton
pruning, and edge distance determination. | [
"Create",
"new",
"instance",
"of",
"KernelInfo",
"with",
"one",
"of",
"the",
"'",
"named",
"'",
"built",
"-",
"in",
"types",
"of",
"kernels",
"used",
"for",
"special",
"purposes",
"such",
"as",
"gaussian",
"blurring",
"skeleton",
"pruning",
"and",
"edge",
"distance",
"determination",
"."
] | [] | [
{
"param": "self",
"type": "VALUE"
},
{
"param": "what",
"type": "VALUE"
},
{
"param": "geometry",
"type": "VALUE"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": "VALUE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "what",
"type": "VALUE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "geometry",
"type": "VALUE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c2304a521de33d97841756f8514f3c1870b026f0 | vsvld/rmagick | ext/RMagick/rmmain.c | [
"MIT"
] | C | managed_memory_enable | void | static inline void managed_memory_enable(VALUE enable)
{
if (enable)
{
SetMagickMemoryMethods(rm_malloc, rm_realloc, rm_free);
}
rb_define_const(Module_Magick, "MANAGED_MEMORY", enable);
} | /**
* Use managed memory.
*
* No Ruby usage (internal function)
*/ | Use managed memory.
No Ruby usage (internal function) | [
"Use",
"managed",
"memory",
".",
"No",
"Ruby",
"usage",
"(",
"internal",
"function",
")"
] | static inline void managed_memory_enable(VALUE enable)
{
if (enable)
{
SetMagickMemoryMethods(rm_malloc, rm_realloc, rm_free);
}
rb_define_const(Module_Magick, "MANAGED_MEMORY", enable);
} | [
"static",
"inline",
"void",
"managed_memory_enable",
"(",
"VALUE",
"enable",
")",
"{",
"if",
"(",
"enable",
")",
"{",
"SetMagickMemoryMethods",
"(",
"rm_malloc",
",",
"rm_realloc",
",",
"rm_free",
")",
";",
"}",
"rb_define_const",
"(",
"Module_Magick",
",",
"\"",
"\"",
",",
"enable",
")",
";",
"}"
] | Use managed memory. | [
"Use",
"managed",
"memory",
"."
] | [] | [
{
"param": "enable",
"type": "VALUE"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "enable",
"type": "VALUE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c2304a521de33d97841756f8514f3c1870b026f0 | vsvld/rmagick | ext/RMagick/rmmain.c | [
"MIT"
] | C | features_constant | void | static void
features_constant(void)
{
VALUE features;
// 6.5.7 - latest (7.0.0)
features = rb_str_new2(GetMagickFeatures());
rb_obj_freeze(features);
rb_define_const(Module_Magick, "Magick_features", features);
RB_GC_GUARD(features);
} | /**
* Create Features constant.
*
* No Ruby usage (internal function)
*/ | Create Features constant.
No Ruby usage (internal function) | [
"Create",
"Features",
"constant",
".",
"No",
"Ruby",
"usage",
"(",
"internal",
"function",
")"
] | static void
features_constant(void)
{
VALUE features;
features = rb_str_new2(GetMagickFeatures());
rb_obj_freeze(features);
rb_define_const(Module_Magick, "Magick_features", features);
RB_GC_GUARD(features);
} | [
"static",
"void",
"features_constant",
"(",
"void",
")",
"{",
"VALUE",
"features",
";",
"features",
"=",
"rb_str_new2",
"(",
"GetMagickFeatures",
"(",
")",
")",
";",
"rb_obj_freeze",
"(",
"features",
")",
";",
"rb_define_const",
"(",
"Module_Magick",
",",
"\"",
"\"",
",",
"features",
")",
";",
"RB_GC_GUARD",
"(",
"features",
")",
";",
"}"
] | Create Features constant. | [
"Create",
"Features",
"constant",
"."
] | [
"// 6.5.7 - latest (7.0.0)"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8ba05a8c0db822d7223f8c24d2f45672135352c6 | TheRyanKing87/Kernel-threads | kernel/proc.c | [
"Xnet",
"X11"
] | C | userinit | void | void
userinit(void)
{
struct proc *p;
extern char _binary_initcode_start[], _binary_initcode_size[];
p = allocproc();
acquire(&ptable.lock);
initproc = p;
if((p->pgdir = setupkvm()) == 0)
panic("userinit: out of memory?");
inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);
p->sz = PGSIZE;
memset(p->tf, 0, sizeof(*p->tf));
p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
p->tf->es = p->tf->ds;
p->tf->ss = p->tf->ds;
p->tf->eflags = FL_IF;
p->tf->esp = PGSIZE;
p->tf->eip = 0; // beginning of initcode.S
p->priority = 1; // P2 - initialize this (and all) procs to priority 1
p->wokeUp = 0;
safestrcpy(p->name, "initcode", sizeof(p->name));
p->cwd = namei("/");
p->state = RUNNABLE;
release(&ptable.lock);
} | // Set up first user process. | Set up first user process. | [
"Set",
"up",
"first",
"user",
"process",
"."
] | void
userinit(void)
{
struct proc *p;
extern char _binary_initcode_start[], _binary_initcode_size[];
p = allocproc();
acquire(&ptable.lock);
initproc = p;
if((p->pgdir = setupkvm()) == 0)
panic("userinit: out of memory?");
inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);
p->sz = PGSIZE;
memset(p->tf, 0, sizeof(*p->tf));
p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
p->tf->es = p->tf->ds;
p->tf->ss = p->tf->ds;
p->tf->eflags = FL_IF;
p->tf->esp = PGSIZE;
p->tf->eip = 0;
p->priority = 1;
p->wokeUp = 0;
safestrcpy(p->name, "initcode", sizeof(p->name));
p->cwd = namei("/");
p->state = RUNNABLE;
release(&ptable.lock);
} | [
"void",
"userinit",
"(",
"void",
")",
"{",
"struct",
"proc",
"*",
"p",
";",
"extern",
"char",
"_binary_initcode_start",
"[",
"]",
",",
"_binary_initcode_size",
"[",
"]",
";",
"p",
"=",
"allocproc",
"(",
")",
";",
"acquire",
"(",
"&",
"ptable",
".",
"lock",
")",
";",
"initproc",
"=",
"p",
";",
"if",
"(",
"(",
"p",
"->",
"pgdir",
"=",
"setupkvm",
"(",
")",
")",
"==",
"0",
")",
"panic",
"(",
"\"",
"\"",
")",
";",
"inituvm",
"(",
"p",
"->",
"pgdir",
",",
"_binary_initcode_start",
",",
"(",
"int",
")",
"_binary_initcode_size",
")",
";",
"p",
"->",
"sz",
"=",
"PGSIZE",
";",
"memset",
"(",
"p",
"->",
"tf",
",",
"0",
",",
"sizeof",
"(",
"*",
"p",
"->",
"tf",
")",
")",
";",
"p",
"->",
"tf",
"->",
"cs",
"=",
"(",
"SEG_UCODE",
"<<",
"3",
")",
"|",
"DPL_USER",
";",
"p",
"->",
"tf",
"->",
"ds",
"=",
"(",
"SEG_UDATA",
"<<",
"3",
")",
"|",
"DPL_USER",
";",
"p",
"->",
"tf",
"->",
"es",
"=",
"p",
"->",
"tf",
"->",
"ds",
";",
"p",
"->",
"tf",
"->",
"ss",
"=",
"p",
"->",
"tf",
"->",
"ds",
";",
"p",
"->",
"tf",
"->",
"eflags",
"=",
"FL_IF",
";",
"p",
"->",
"tf",
"->",
"esp",
"=",
"PGSIZE",
";",
"p",
"->",
"tf",
"->",
"eip",
"=",
"0",
";",
"p",
"->",
"priority",
"=",
"1",
";",
"p",
"->",
"wokeUp",
"=",
"0",
";",
"safestrcpy",
"(",
"p",
"->",
"name",
",",
"\"",
"\"",
",",
"sizeof",
"(",
"p",
"->",
"name",
")",
")",
";",
"p",
"->",
"cwd",
"=",
"namei",
"(",
"\"",
"\"",
")",
";",
"p",
"->",
"state",
"=",
"RUNNABLE",
";",
"release",
"(",
"&",
"ptable",
".",
"lock",
")",
";",
"}"
] | Set up first user process. | [
"Set",
"up",
"first",
"user",
"process",
"."
] | [
"// beginning of initcode.S",
"// P2 - initialize this (and all) procs to priority 1"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8ba05a8c0db822d7223f8c24d2f45672135352c6 | TheRyanKing87/Kernel-threads | kernel/proc.c | [
"Xnet",
"X11"
] | C | growproc | int | int
growproc(int n)
{
//adding threads stuff
uint sz;
struct proc *p;
pde_t *pageDirectory = proc->pgdir;
sz = proc->sz;
//for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
//if(p->pgdir != proc->pgdir)
// continue;
//if(n > 0){
// if((sz = allocuvm(p->pgdir, sz, sz + n)) == 0)
// return -1;
//} else if(n < 0){
// if((sz = deallocuvm(p->pgdir, sz, sz + n)) == 0)
// return -1;
//}
//p->sz = sz;
//}
if(n > 0){
if((sz = allocuvm(proc->pgdir, sz, sz + n)) == 0)
return -1;
} else if(n < 0){
if((sz = deallocuvm(proc->pgdir, sz, sz + n)) == 0)
return -1;
}
proc->sz = sz;
acquire(&ptable.lock);
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
if(p->pgdir == pageDirectory){
p->sz = sz;
acquire(&lock);
switchuvm(p);
release(&lock);
}
}
release(&ptable.lock);
switchuvm(proc);
return 0;
} | // Grow current process's memory by n bytes.
// Return 0 on success, -1 on failure. | Grow current process's memory by n bytes.
Return 0 on success, -1 on failure. | [
"Grow",
"current",
"process",
"'",
"s",
"memory",
"by",
"n",
"bytes",
".",
"Return",
"0",
"on",
"success",
"-",
"1",
"on",
"failure",
"."
] | int
growproc(int n)
{
uint sz;
struct proc *p;
pde_t *pageDirectory = proc->pgdir;
sz = proc->sz;
if(n > 0){
if((sz = allocuvm(proc->pgdir, sz, sz + n)) == 0)
return -1;
} else if(n < 0){
if((sz = deallocuvm(proc->pgdir, sz, sz + n)) == 0)
return -1;
}
proc->sz = sz;
acquire(&ptable.lock);
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
if(p->pgdir == pageDirectory){
p->sz = sz;
acquire(&lock);
switchuvm(p);
release(&lock);
}
}
release(&ptable.lock);
switchuvm(proc);
return 0;
} | [
"int",
"growproc",
"(",
"int",
"n",
")",
"{",
"uint",
"sz",
";",
"struct",
"proc",
"*",
"p",
";",
"pde_t",
"*",
"pageDirectory",
"=",
"proc",
"->",
"pgdir",
";",
"sz",
"=",
"proc",
"->",
"sz",
";",
"if",
"(",
"n",
">",
"0",
")",
"{",
"if",
"(",
"(",
"sz",
"=",
"allocuvm",
"(",
"proc",
"->",
"pgdir",
",",
"sz",
",",
"sz",
"+",
"n",
")",
")",
"==",
"0",
")",
"return",
"-1",
";",
"}",
"else",
"if",
"(",
"n",
"<",
"0",
")",
"{",
"if",
"(",
"(",
"sz",
"=",
"deallocuvm",
"(",
"proc",
"->",
"pgdir",
",",
"sz",
",",
"sz",
"+",
"n",
")",
")",
"==",
"0",
")",
"return",
"-1",
";",
"}",
"proc",
"->",
"sz",
"=",
"sz",
";",
"acquire",
"(",
"&",
"ptable",
".",
"lock",
")",
";",
"for",
"(",
"p",
"=",
"ptable",
".",
"proc",
";",
"p",
"<",
"&",
"ptable",
".",
"proc",
"[",
"NPROC",
"]",
";",
"p",
"++",
")",
"{",
"if",
"(",
"p",
"->",
"pgdir",
"==",
"pageDirectory",
")",
"{",
"p",
"->",
"sz",
"=",
"sz",
";",
"acquire",
"(",
"&",
"lock",
")",
";",
"switchuvm",
"(",
"p",
")",
";",
"release",
"(",
"&",
"lock",
")",
";",
"}",
"}",
"release",
"(",
"&",
"ptable",
".",
"lock",
")",
";",
"switchuvm",
"(",
"proc",
")",
";",
"return",
"0",
";",
"}"
] | Grow current process's memory by n bytes. | [
"Grow",
"current",
"process",
"'",
"s",
"memory",
"by",
"n",
"bytes",
"."
] | [
"//adding threads stuff",
"//for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){",
"//if(p->pgdir != proc->pgdir)",
"// continue;",
"//if(n > 0){",
"// if((sz = allocuvm(p->pgdir, sz, sz + n)) == 0)",
"//\treturn -1;",
"//} else if(n < 0){",
"// if((sz = deallocuvm(p->pgdir, sz, sz + n)) == 0)",
"//\treturn -1;",
"//}",
"//p->sz = sz;",
"//}"
] | [
{
"param": "n",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8ba05a8c0db822d7223f8c24d2f45672135352c6 | TheRyanKing87/Kernel-threads | kernel/proc.c | [
"Xnet",
"X11"
] | C | fork | int | int
fork(void)
{
int i, pid;
struct proc *np;
// Allocate process.
if((np = allocproc()) == 0)
return -1;
// Copy process state from p.
if((np->pgdir = copyuvm(proc->pgdir, proc->sz)) == 0){
kfree(np->kstack);
np->kstack = 0;
np->state = UNUSED;
return -1;
}
np->sz = proc->sz;
np->parent = proc;
*np->tf = *proc->tf;
// Clear %eax so that fork returns 0 in the child.
np->tf->eax = 0;
//pretending this is clone not fork
//set up new user stack
//and registers (np->tf->eip,
//np->tf->esp)
for(i = 0; i < NOFILE; i++)
if(proc->ofile[i])
np->ofile[i] = filedup(proc->ofile[i]);
np->cwd = idup(proc->cwd);
pid = np->pid;
np->state = RUNNABLE;
safestrcpy(np->name, proc->name, sizeof(proc->name));
np->priority = proc->priority; // P2 - make sure priority is copied
np->wokeUp = 0;
return pid;
} | // Create a new process copying p as the parent.
// Sets up stack to return as if from system call.
// Caller must set state of returned proc to RUNNABLE. | Create a new process copying p as the parent.
Sets up stack to return as if from system call.
Caller must set state of returned proc to RUNNABLE. | [
"Create",
"a",
"new",
"process",
"copying",
"p",
"as",
"the",
"parent",
".",
"Sets",
"up",
"stack",
"to",
"return",
"as",
"if",
"from",
"system",
"call",
".",
"Caller",
"must",
"set",
"state",
"of",
"returned",
"proc",
"to",
"RUNNABLE",
"."
] | int
fork(void)
{
int i, pid;
struct proc *np;
if((np = allocproc()) == 0)
return -1;
if((np->pgdir = copyuvm(proc->pgdir, proc->sz)) == 0){
kfree(np->kstack);
np->kstack = 0;
np->state = UNUSED;
return -1;
}
np->sz = proc->sz;
np->parent = proc;
*np->tf = *proc->tf;
np->tf->eax = 0;
for(i = 0; i < NOFILE; i++)
if(proc->ofile[i])
np->ofile[i] = filedup(proc->ofile[i]);
np->cwd = idup(proc->cwd);
pid = np->pid;
np->state = RUNNABLE;
safestrcpy(np->name, proc->name, sizeof(proc->name));
np->priority = proc->priority;
np->wokeUp = 0;
return pid;
} | [
"int",
"fork",
"(",
"void",
")",
"{",
"int",
"i",
",",
"pid",
";",
"struct",
"proc",
"*",
"np",
";",
"if",
"(",
"(",
"np",
"=",
"allocproc",
"(",
")",
")",
"==",
"0",
")",
"return",
"-1",
";",
"if",
"(",
"(",
"np",
"->",
"pgdir",
"=",
"copyuvm",
"(",
"proc",
"->",
"pgdir",
",",
"proc",
"->",
"sz",
")",
")",
"==",
"0",
")",
"{",
"kfree",
"(",
"np",
"->",
"kstack",
")",
";",
"np",
"->",
"kstack",
"=",
"0",
";",
"np",
"->",
"state",
"=",
"UNUSED",
";",
"return",
"-1",
";",
"}",
"np",
"->",
"sz",
"=",
"proc",
"->",
"sz",
";",
"np",
"->",
"parent",
"=",
"proc",
";",
"*",
"np",
"->",
"tf",
"=",
"*",
"proc",
"->",
"tf",
";",
"np",
"->",
"tf",
"->",
"eax",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"NOFILE",
";",
"i",
"++",
")",
"if",
"(",
"proc",
"->",
"ofile",
"[",
"i",
"]",
")",
"np",
"->",
"ofile",
"[",
"i",
"]",
"=",
"filedup",
"(",
"proc",
"->",
"ofile",
"[",
"i",
"]",
")",
";",
"np",
"->",
"cwd",
"=",
"idup",
"(",
"proc",
"->",
"cwd",
")",
";",
"pid",
"=",
"np",
"->",
"pid",
";",
"np",
"->",
"state",
"=",
"RUNNABLE",
";",
"safestrcpy",
"(",
"np",
"->",
"name",
",",
"proc",
"->",
"name",
",",
"sizeof",
"(",
"proc",
"->",
"name",
")",
")",
";",
"np",
"->",
"priority",
"=",
"proc",
"->",
"priority",
";",
"np",
"->",
"wokeUp",
"=",
"0",
";",
"return",
"pid",
";",
"}"
] | Create a new process copying p as the parent. | [
"Create",
"a",
"new",
"process",
"copying",
"p",
"as",
"the",
"parent",
"."
] | [
"// Allocate process.",
"// Copy process state from p.",
"// Clear %eax so that fork returns 0 in the child.",
"//pretending this is clone not fork",
"//set up new user stack",
"//and registers (np->tf->eip,",
"//np->tf->esp)",
"// P2 - make sure priority is copied"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8ba05a8c0db822d7223f8c24d2f45672135352c6 | TheRyanKing87/Kernel-threads | kernel/proc.c | [
"Xnet",
"X11"
] | C | wait | int | int
wait(void)
{
struct proc *p;
int havekids, pid;
acquire(&ptable.lock);
for(;;){
// Scan through table looking for zombie children.
havekids = 0;
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
if((p->parent != proc) || (p->pgdir == proc->pgdir))
continue;
havekids = 1;
if(p->state == ZOMBIE){
// Found one.
pid = p->pid;
kfree(p->kstack);
p->kstack = 0;
freevm(p->pgdir);
p->state = UNUSED;
p->pid = 0;
p->parent = 0;
p->name[0] = 0;
p->killed = 0;
release(&ptable.lock);
return pid;
}
}
// No point waiting if we don't have any children.
if(!havekids || proc->killed){
release(&ptable.lock);
//freevm(proc->pgdir);
return -1;
}
//freevm(proc->pgdir);
// Wait for children to exit. (See wakeup1 call in proc_exit.)
sleep(proc, &ptable.lock); //DOC: wait-sleep
}
} | // Wait for a child process to exit and return its pid.
// Return -1 if this process has no children. | Wait for a child process to exit and return its pid.
Return -1 if this process has no children. | [
"Wait",
"for",
"a",
"child",
"process",
"to",
"exit",
"and",
"return",
"its",
"pid",
".",
"Return",
"-",
"1",
"if",
"this",
"process",
"has",
"no",
"children",
"."
] | int
wait(void)
{
struct proc *p;
int havekids, pid;
acquire(&ptable.lock);
for(;;){
havekids = 0;
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
if((p->parent != proc) || (p->pgdir == proc->pgdir))
continue;
havekids = 1;
if(p->state == ZOMBIE){
pid = p->pid;
kfree(p->kstack);
p->kstack = 0;
freevm(p->pgdir);
p->state = UNUSED;
p->pid = 0;
p->parent = 0;
p->name[0] = 0;
p->killed = 0;
release(&ptable.lock);
return pid;
}
}
if(!havekids || proc->killed){
release(&ptable.lock);
return -1;
}
sleep(proc, &ptable.lock);
}
} | [
"int",
"wait",
"(",
"void",
")",
"{",
"struct",
"proc",
"*",
"p",
";",
"int",
"havekids",
",",
"pid",
";",
"acquire",
"(",
"&",
"ptable",
".",
"lock",
")",
";",
"for",
"(",
";",
";",
")",
"{",
"havekids",
"=",
"0",
";",
"for",
"(",
"p",
"=",
"ptable",
".",
"proc",
";",
"p",
"<",
"&",
"ptable",
".",
"proc",
"[",
"NPROC",
"]",
";",
"p",
"++",
")",
"{",
"if",
"(",
"(",
"p",
"->",
"parent",
"!=",
"proc",
")",
"||",
"(",
"p",
"->",
"pgdir",
"==",
"proc",
"->",
"pgdir",
")",
")",
"continue",
";",
"havekids",
"=",
"1",
";",
"if",
"(",
"p",
"->",
"state",
"==",
"ZOMBIE",
")",
"{",
"pid",
"=",
"p",
"->",
"pid",
";",
"kfree",
"(",
"p",
"->",
"kstack",
")",
";",
"p",
"->",
"kstack",
"=",
"0",
";",
"freevm",
"(",
"p",
"->",
"pgdir",
")",
";",
"p",
"->",
"state",
"=",
"UNUSED",
";",
"p",
"->",
"pid",
"=",
"0",
";",
"p",
"->",
"parent",
"=",
"0",
";",
"p",
"->",
"name",
"[",
"0",
"]",
"=",
"0",
";",
"p",
"->",
"killed",
"=",
"0",
";",
"release",
"(",
"&",
"ptable",
".",
"lock",
")",
";",
"return",
"pid",
";",
"}",
"}",
"if",
"(",
"!",
"havekids",
"||",
"proc",
"->",
"killed",
")",
"{",
"release",
"(",
"&",
"ptable",
".",
"lock",
")",
";",
"return",
"-1",
";",
"}",
"sleep",
"(",
"proc",
",",
"&",
"ptable",
".",
"lock",
")",
";",
"}",
"}"
] | Wait for a child process to exit and return its pid. | [
"Wait",
"for",
"a",
"child",
"process",
"to",
"exit",
"and",
"return",
"its",
"pid",
"."
] | [
"// Scan through table looking for zombie children.",
"// Found one.",
"// No point waiting if we don't have any children.",
"//freevm(proc->pgdir);",
"//freevm(proc->pgdir);",
"// Wait for children to exit. (See wakeup1 call in proc_exit.)",
"//DOC: wait-sleep"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8ba05a8c0db822d7223f8c24d2f45672135352c6 | TheRyanKing87/Kernel-threads | kernel/proc.c | [
"Xnet",
"X11"
] | C | scheduler | void | void
scheduler(void)
{
// put P2 stuff in here
struct proc *p;
struct proc *q;
struct pstat processStat;
int bookmarkPID = -1;
int wokeUpNum = 0;
for(;;){
// Enable interrupts on this processor.
sti();
acquire(&ptable.lock);
//if (numberOfPriority2 == 0) {
//numberOfPriority2 = 0;
wokeUpNum = 0;
for(q = ptable.proc; q < &ptable.proc[NPROC]; q++){
if ((q->wokeUp == 1) && (q->priority == 2)) {
wokeUpNum++;
}
}
// Loop over process table looking for process to run.
//acquire(&ptable.lock);
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
if(p->state != RUNNABLE) {
continue;
}
else { //runnable
if (p->priority != 2) { //not high priority
if (bookmarkPID < 0) { //no bookmarks - start tracking
bookmarkPID = p->pid;
continue;
}
else if (bookmarkPID == p->pid) { //already have bookmark - run it
bookmarkPID = -1;
}
}
else if (p->priority == 2) {
if (wokeUpNum > 0) {
if (p->wokeUp == 0) {
continue;
}
else if (p->wokeUp == 1) {
p->wokeUp = 0;
bookmarkPID = -1; //high priority
}
}
else {
if (p->wokeUp == 1) {
p->wokeUp = 0;
}
bookmarkPID = -1;
}
}
}
// Switch to chosen process. It is the process's job
// to release ptable.lock and then reacquire it
// before jumping back to us.
proc = p;
int pid = p->pid;
switchuvm(p);
p->state = RUNNING;
processStat.pid[pid] = pid;
processStat.inuse[pid] = 1;
swtch(&cpu->scheduler, proc->context);
processStat.inuse[pid] = 0;
switchkvm();
int priority = proc->priority;
if (priority == 1) {
p->lticks++;
}
if (priority == 2) {
p->hticks++;
}
// Process is done running for now.
// It should have changed its p->state before coming back.
proc = 0;
}
release(&ptable.lock);
}
} | // Per-CPU process scheduler.
// Each CPU calls scheduler() after setting itself up.
// Scheduler never returns. It loops, doing:
// - choose a process to run
// - swtch to start running that process
// - eventually that process transfers control
// via swtch back to the scheduler. | Per-CPU process scheduler.
Each CPU calls scheduler() after setting itself up.
Scheduler never returns. It loops, doing:
choose a process to run
swtch to start running that process
eventually that process transfers control
via swtch back to the scheduler. | [
"Per",
"-",
"CPU",
"process",
"scheduler",
".",
"Each",
"CPU",
"calls",
"scheduler",
"()",
"after",
"setting",
"itself",
"up",
".",
"Scheduler",
"never",
"returns",
".",
"It",
"loops",
"doing",
":",
"choose",
"a",
"process",
"to",
"run",
"swtch",
"to",
"start",
"running",
"that",
"process",
"eventually",
"that",
"process",
"transfers",
"control",
"via",
"swtch",
"back",
"to",
"the",
"scheduler",
"."
] | void
scheduler(void)
{
struct proc *p;
struct proc *q;
struct pstat processStat;
int bookmarkPID = -1;
int wokeUpNum = 0;
for(;;){
sti();
acquire(&ptable.lock);
wokeUpNum = 0;
for(q = ptable.proc; q < &ptable.proc[NPROC]; q++){
if ((q->wokeUp == 1) && (q->priority == 2)) {
wokeUpNum++;
}
}
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
if(p->state != RUNNABLE) {
continue;
}
else {
if (p->priority != 2) {
if (bookmarkPID < 0) {
bookmarkPID = p->pid;
continue;
}
else if (bookmarkPID == p->pid) {
bookmarkPID = -1;
}
}
else if (p->priority == 2) {
if (wokeUpNum > 0) {
if (p->wokeUp == 0) {
continue;
}
else if (p->wokeUp == 1) {
p->wokeUp = 0;
bookmarkPID = -1;
}
}
else {
if (p->wokeUp == 1) {
p->wokeUp = 0;
}
bookmarkPID = -1;
}
}
}
proc = p;
int pid = p->pid;
switchuvm(p);
p->state = RUNNING;
processStat.pid[pid] = pid;
processStat.inuse[pid] = 1;
swtch(&cpu->scheduler, proc->context);
processStat.inuse[pid] = 0;
switchkvm();
int priority = proc->priority;
if (priority == 1) {
p->lticks++;
}
if (priority == 2) {
p->hticks++;
}
proc = 0;
}
release(&ptable.lock);
}
} | [
"void",
"scheduler",
"(",
"void",
")",
"{",
"struct",
"proc",
"*",
"p",
";",
"struct",
"proc",
"*",
"q",
";",
"struct",
"pstat",
"processStat",
";",
"int",
"bookmarkPID",
"=",
"-1",
";",
"int",
"wokeUpNum",
"=",
"0",
";",
"for",
"(",
";",
";",
")",
"{",
"sti",
"(",
")",
";",
"acquire",
"(",
"&",
"ptable",
".",
"lock",
")",
";",
"wokeUpNum",
"=",
"0",
";",
"for",
"(",
"q",
"=",
"ptable",
".",
"proc",
";",
"q",
"<",
"&",
"ptable",
".",
"proc",
"[",
"NPROC",
"]",
";",
"q",
"++",
")",
"{",
"if",
"(",
"(",
"q",
"->",
"wokeUp",
"==",
"1",
")",
"&&",
"(",
"q",
"->",
"priority",
"==",
"2",
")",
")",
"{",
"wokeUpNum",
"++",
";",
"}",
"}",
"for",
"(",
"p",
"=",
"ptable",
".",
"proc",
";",
"p",
"<",
"&",
"ptable",
".",
"proc",
"[",
"NPROC",
"]",
";",
"p",
"++",
")",
"{",
"if",
"(",
"p",
"->",
"state",
"!=",
"RUNNABLE",
")",
"{",
"continue",
";",
"}",
"else",
"{",
"if",
"(",
"p",
"->",
"priority",
"!=",
"2",
")",
"{",
"if",
"(",
"bookmarkPID",
"<",
"0",
")",
"{",
"bookmarkPID",
"=",
"p",
"->",
"pid",
";",
"continue",
";",
"}",
"else",
"if",
"(",
"bookmarkPID",
"==",
"p",
"->",
"pid",
")",
"{",
"bookmarkPID",
"=",
"-1",
";",
"}",
"}",
"else",
"if",
"(",
"p",
"->",
"priority",
"==",
"2",
")",
"{",
"if",
"(",
"wokeUpNum",
">",
"0",
")",
"{",
"if",
"(",
"p",
"->",
"wokeUp",
"==",
"0",
")",
"{",
"continue",
";",
"}",
"else",
"if",
"(",
"p",
"->",
"wokeUp",
"==",
"1",
")",
"{",
"p",
"->",
"wokeUp",
"=",
"0",
";",
"bookmarkPID",
"=",
"-1",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"p",
"->",
"wokeUp",
"==",
"1",
")",
"{",
"p",
"->",
"wokeUp",
"=",
"0",
";",
"}",
"bookmarkPID",
"=",
"-1",
";",
"}",
"}",
"}",
"proc",
"=",
"p",
";",
"int",
"pid",
"=",
"p",
"->",
"pid",
";",
"switchuvm",
"(",
"p",
")",
";",
"p",
"->",
"state",
"=",
"RUNNING",
";",
"processStat",
".",
"pid",
"[",
"pid",
"]",
"=",
"pid",
";",
"processStat",
".",
"inuse",
"[",
"pid",
"]",
"=",
"1",
";",
"swtch",
"(",
"&",
"cpu",
"->",
"scheduler",
",",
"proc",
"->",
"context",
")",
";",
"processStat",
".",
"inuse",
"[",
"pid",
"]",
"=",
"0",
";",
"switchkvm",
"(",
")",
";",
"int",
"priority",
"=",
"proc",
"->",
"priority",
";",
"if",
"(",
"priority",
"==",
"1",
")",
"{",
"p",
"->",
"lticks",
"++",
";",
"}",
"if",
"(",
"priority",
"==",
"2",
")",
"{",
"p",
"->",
"hticks",
"++",
";",
"}",
"proc",
"=",
"0",
";",
"}",
"release",
"(",
"&",
"ptable",
".",
"lock",
")",
";",
"}",
"}"
] | Per-CPU process scheduler. | [
"Per",
"-",
"CPU",
"process",
"scheduler",
"."
] | [
"// put P2 stuff in here",
"// Enable interrupts on this processor.",
"//if (numberOfPriority2 == 0) {",
"//numberOfPriority2 = 0;",
"// Loop over process table looking for process to run.",
"//acquire(&ptable.lock);",
"//runnable",
"//not high priority",
"//no bookmarks - start tracking",
"//already have bookmark - run it",
"//high priority",
"// Switch to chosen process. It is the process's job",
"// to release ptable.lock and then reacquire it",
"// before jumping back to us.",
"// Process is done running for now.",
"// It should have changed its p->state before coming back."
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8ba05a8c0db822d7223f8c24d2f45672135352c6 | TheRyanKing87/Kernel-threads | kernel/proc.c | [
"Xnet",
"X11"
] | C | wakeup1 | void | static void
wakeup1(void *chan)
{
struct proc *p;
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
if(p->state == SLEEPING && p->chan == chan) {
p->state = RUNNABLE;
p->wokeUp = 1; //P2
}
} | // Wake up all processes sleeping on chan.
// The ptable lock must be held. | Wake up all processes sleeping on chan.
The ptable lock must be held. | [
"Wake",
"up",
"all",
"processes",
"sleeping",
"on",
"chan",
".",
"The",
"ptable",
"lock",
"must",
"be",
"held",
"."
] | static void
wakeup1(void *chan)
{
struct proc *p;
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
if(p->state == SLEEPING && p->chan == chan) {
p->state = RUNNABLE;
p->wokeUp = 1;
}
} | [
"static",
"void",
"wakeup1",
"(",
"void",
"*",
"chan",
")",
"{",
"struct",
"proc",
"*",
"p",
";",
"for",
"(",
"p",
"=",
"ptable",
".",
"proc",
";",
"p",
"<",
"&",
"ptable",
".",
"proc",
"[",
"NPROC",
"]",
";",
"p",
"++",
")",
"if",
"(",
"p",
"->",
"state",
"==",
"SLEEPING",
"&&",
"p",
"->",
"chan",
"==",
"chan",
")",
"{",
"p",
"->",
"state",
"=",
"RUNNABLE",
";",
"p",
"->",
"wokeUp",
"=",
"1",
";",
"}",
"}"
] | Wake up all processes sleeping on chan. | [
"Wake",
"up",
"all",
"processes",
"sleeping",
"on",
"chan",
"."
] | [
"//P2"
] | [
{
"param": "chan",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chan",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
46b8c05c537b4d686da58719c82968b051e8c3b9 | zrajani/Game_of_Life | Game of Life Project Files/source/cells.c | [
"MIT"
] | C | countLiveNeighbours | size_t | size_t countLiveNeighbours (size_t row, size_t col)
{
size_t cell_count = 0;
for (size_t i = row - 1; i <= row + 1; i++)
{
for (size_t j = col - 1; j <= col + 1; j++)
{
// To make sure that you don't count the cell whose neighbours are counted
if (i != 0 && j != 0)
{
cell_count = cell_count + (size_t) env[(i + config_NC) % config_NC][(j + config_MC)% config_MC];
//cell_count=(size_t)env[i-1][j-1]+(size_t)env[i-1][j]+(size_t)env[i-1][j+1]+(size_t)env[i][j-1]+
//(size_t)env[i][j+1]+(size_t)env[i+1][j-1]+(size_t)env[i+1][j]+(size_t)env[i+1][j+1];
}
}
}
cell_count=cell_count - env[row][col];
return cell_count;
} | /*
* function counts the number of live neighbours of a cell located
* at row r and column c of the env array
*
* for reference, neighbours are designated as follows:
* a b c
* d X e
* f g h
*
*
*/ | function counts the number of live neighbours of a cell located
at row r and column c of the env array
for reference, neighbours are designated as follows:
a b c
d X e
f g h | [
"function",
"counts",
"the",
"number",
"of",
"live",
"neighbours",
"of",
"a",
"cell",
"located",
"at",
"row",
"r",
"and",
"column",
"c",
"of",
"the",
"env",
"array",
"for",
"reference",
"neighbours",
"are",
"designated",
"as",
"follows",
":",
"a",
"b",
"c",
"d",
"X",
"e",
"f",
"g",
"h"
] | size_t countLiveNeighbours (size_t row, size_t col)
{
size_t cell_count = 0;
for (size_t i = row - 1; i <= row + 1; i++)
{
for (size_t j = col - 1; j <= col + 1; j++)
{
if (i != 0 && j != 0)
{
cell_count = cell_count + (size_t) env[(i + config_NC) % config_NC][(j + config_MC)% config_MC];
}
}
}
cell_count=cell_count - env[row][col];
return cell_count;
} | [
"size_t",
"countLiveNeighbours",
"(",
"size_t",
"row",
",",
"size_t",
"col",
")",
"{",
"size_t",
"cell_count",
"=",
"0",
";",
"for",
"(",
"size_t",
"i",
"=",
"row",
"-",
"1",
";",
"i",
"<=",
"row",
"+",
"1",
";",
"i",
"++",
")",
"{",
"for",
"(",
"size_t",
"j",
"=",
"col",
"-",
"1",
";",
"j",
"<=",
"col",
"+",
"1",
";",
"j",
"++",
")",
"{",
"if",
"(",
"i",
"!=",
"0",
"&&",
"j",
"!=",
"0",
")",
"{",
"cell_count",
"=",
"cell_count",
"+",
"(",
"size_t",
")",
"env",
"[",
"(",
"i",
"+",
"config_NC",
")",
"%",
"config_NC",
"]",
"[",
"(",
"j",
"+",
"config_MC",
")",
"%",
"config_MC",
"]",
";",
"}",
"}",
"}",
"cell_count",
"=",
"cell_count",
"-",
"env",
"[",
"row",
"]",
"[",
"col",
"]",
";",
"return",
"cell_count",
";",
"}"
] | function counts the number of live neighbours of a cell located
at row r and column c of the env array | [
"function",
"counts",
"the",
"number",
"of",
"live",
"neighbours",
"of",
"a",
"cell",
"located",
"at",
"row",
"r",
"and",
"column",
"c",
"of",
"the",
"env",
"array"
] | [
"// To make sure that you don't count the cell whose neighbours are counted",
"//cell_count=(size_t)env[i-1][j-1]+(size_t)env[i-1][j]+(size_t)env[i-1][j+1]+(size_t)env[i][j-1]+",
"//(size_t)env[i][j+1]+(size_t)env[i+1][j-1]+(size_t)env[i+1][j]+(size_t)env[i+1][j+1];"
] | [
{
"param": "row",
"type": "size_t"
},
{
"param": "col",
"type": "size_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "row",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "col",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
46b8c05c537b4d686da58719c82968b051e8c3b9 | zrajani/Game_of_Life | Game of Life Project Files/source/cells.c | [
"MIT"
] | C | updateCell | void | void updateCell (size_t r, size_t c)
{
cell_t state_cell = env[r][c];
size_t live_neighbours = countLiveNeighbours (r, c);
if (state_cell == 0 && (live_neighbours == 3))
{
update_env[r][c] = state_cell=live;
}
else if (state_cell == 1 && (live_neighbours > 3))
{
update_env[r][c] =state_cell= dead;
}
else if (state_cell == 1 && (live_neighbours < 2))
{
update_env[r][c] =state_cell= dead;
}
else
{
update_env[r][c]=state_cell;
}
} | /*
* update cell located at row r and column c in env (indicated by X):
*
* a b c
* d X e
* f g h
*
* with nearest neighbours indicated as shown from a, b, ..., h.
*
* this function features Conway's rules:
* - if a cell is dead but surrounded by exactly three live neighbours, it sprouts to life (birth)
* - if a cell is live but has more than 4 live neighbours, it dies (overpopulation)
* - if a cell is live but has fewer than 2 live neighbours, it dies (underpopulation)
* - all other dead or live cells remain the same to the next generation (i.e., a live cell must
* have exactly three neighbours to survive)
*
*/ | update cell located at row r and column c in env (indicated by X):
a b c
d X e
f g h
with nearest neighbours indicated as shown from a, b, ..., h.
this function features Conway's rules:
- if a cell is dead but surrounded by exactly three live neighbours, it sprouts to life (birth)
- if a cell is live but has more than 4 live neighbours, it dies (overpopulation)
- if a cell is live but has fewer than 2 live neighbours, it dies (underpopulation)
- all other dead or live cells remain the same to the next generation | [
"update",
"cell",
"located",
"at",
"row",
"r",
"and",
"column",
"c",
"in",
"env",
"(",
"indicated",
"by",
"X",
")",
":",
"a",
"b",
"c",
"d",
"X",
"e",
"f",
"g",
"h",
"with",
"nearest",
"neighbours",
"indicated",
"as",
"shown",
"from",
"a",
"b",
"...",
"h",
".",
"this",
"function",
"features",
"Conway",
"'",
"s",
"rules",
":",
"-",
"if",
"a",
"cell",
"is",
"dead",
"but",
"surrounded",
"by",
"exactly",
"three",
"live",
"neighbours",
"it",
"sprouts",
"to",
"life",
"(",
"birth",
")",
"-",
"if",
"a",
"cell",
"is",
"live",
"but",
"has",
"more",
"than",
"4",
"live",
"neighbours",
"it",
"dies",
"(",
"overpopulation",
")",
"-",
"if",
"a",
"cell",
"is",
"live",
"but",
"has",
"fewer",
"than",
"2",
"live",
"neighbours",
"it",
"dies",
"(",
"underpopulation",
")",
"-",
"all",
"other",
"dead",
"or",
"live",
"cells",
"remain",
"the",
"same",
"to",
"the",
"next",
"generation"
] | void updateCell (size_t r, size_t c)
{
cell_t state_cell = env[r][c];
size_t live_neighbours = countLiveNeighbours (r, c);
if (state_cell == 0 && (live_neighbours == 3))
{
update_env[r][c] = state_cell=live;
}
else if (state_cell == 1 && (live_neighbours > 3))
{
update_env[r][c] =state_cell= dead;
}
else if (state_cell == 1 && (live_neighbours < 2))
{
update_env[r][c] =state_cell= dead;
}
else
{
update_env[r][c]=state_cell;
}
} | [
"void",
"updateCell",
"(",
"size_t",
"r",
",",
"size_t",
"c",
")",
"{",
"cell_t",
"state_cell",
"=",
"env",
"[",
"r",
"]",
"[",
"c",
"]",
";",
"size_t",
"live_neighbours",
"=",
"countLiveNeighbours",
"(",
"r",
",",
"c",
")",
";",
"if",
"(",
"state_cell",
"==",
"0",
"&&",
"(",
"live_neighbours",
"==",
"3",
")",
")",
"{",
"update_env",
"[",
"r",
"]",
"[",
"c",
"]",
"=",
"state_cell",
"=",
"live",
";",
"}",
"else",
"if",
"(",
"state_cell",
"==",
"1",
"&&",
"(",
"live_neighbours",
">",
"3",
")",
")",
"{",
"update_env",
"[",
"r",
"]",
"[",
"c",
"]",
"=",
"state_cell",
"=",
"dead",
";",
"}",
"else",
"if",
"(",
"state_cell",
"==",
"1",
"&&",
"(",
"live_neighbours",
"<",
"2",
")",
")",
"{",
"update_env",
"[",
"r",
"]",
"[",
"c",
"]",
"=",
"state_cell",
"=",
"dead",
";",
"}",
"else",
"{",
"update_env",
"[",
"r",
"]",
"[",
"c",
"]",
"=",
"state_cell",
";",
"}",
"}"
] | update cell located at row r and column c in env (indicated by X):
a b c
d X e
f g h | [
"update",
"cell",
"located",
"at",
"row",
"r",
"and",
"column",
"c",
"in",
"env",
"(",
"indicated",
"by",
"X",
")",
":",
"a",
"b",
"c",
"d",
"X",
"e",
"f",
"g",
"h"
] | [] | [
{
"param": "r",
"type": "size_t"
},
{
"param": "c",
"type": "size_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "r",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "c",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
46b8c05c537b4d686da58719c82968b051e8c3b9 | zrajani/Game_of_Life | Game of Life Project Files/source/cells.c | [
"MIT"
] | C | initEnvironment | void | void initEnvironment (void)
{
// start by reading in a single community
int token;
cell_t datum;
cell_t community_init[config_NC][config_MC];
printf ("\nInitializing environment...\n");
printf (" ... loading template community from stdin\n");
for (size_t i = 0; i != config_NC; ++i)
{
for (size_t j = 0; j != config_MC; ++j)
{
scanf ("%d", &token);
datum = (cell_t) token;
community_init[i][j] = datum;
}
}
printf (" ... done.\n");
printf (" ... creating communities\n");
// copy this community to each community in env to initialize it
for (size_t i = 0; i != config_K; ++i)
{
for (size_t j = 0; j != config_L; ++j)
{
transferCommunity (i, j, community_init);
}
}
printf (" ... done.\n");
} | /*
* seed environment on a community-by-community basis,
* from standard input; we assume that the seed input is exactly
* the size of a community; 9999 indicates end of file;
* run this before started ncurses environment;
*/ | seed environment on a community-by-community basis,
from standard input; we assume that the seed input is exactly
the size of a community; 9999 indicates end of file;
run this before started ncurses environment. | [
"seed",
"environment",
"on",
"a",
"community",
"-",
"by",
"-",
"community",
"basis",
"from",
"standard",
"input",
";",
"we",
"assume",
"that",
"the",
"seed",
"input",
"is",
"exactly",
"the",
"size",
"of",
"a",
"community",
";",
"9999",
"indicates",
"end",
"of",
"file",
";",
"run",
"this",
"before",
"started",
"ncurses",
"environment",
"."
] | void initEnvironment (void)
{
int token;
cell_t datum;
cell_t community_init[config_NC][config_MC];
printf ("\nInitializing environment...\n");
printf (" ... loading template community from stdin\n");
for (size_t i = 0; i != config_NC; ++i)
{
for (size_t j = 0; j != config_MC; ++j)
{
scanf ("%d", &token);
datum = (cell_t) token;
community_init[i][j] = datum;
}
}
printf (" ... done.\n");
printf (" ... creating communities\n");
for (size_t i = 0; i != config_K; ++i)
{
for (size_t j = 0; j != config_L; ++j)
{
transferCommunity (i, j, community_init);
}
}
printf (" ... done.\n");
} | [
"void",
"initEnvironment",
"(",
"void",
")",
"{",
"int",
"token",
";",
"cell_t",
"datum",
";",
"cell_t",
"community_init",
"[",
"config_NC",
"]",
"[",
"config_MC",
"]",
";",
"printf",
"(",
"\"",
"\\n",
"\\n",
"\"",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
")",
";",
"for",
"(",
"size_t",
"i",
"=",
"0",
";",
"i",
"!=",
"config_NC",
";",
"++",
"i",
")",
"{",
"for",
"(",
"size_t",
"j",
"=",
"0",
";",
"j",
"!=",
"config_MC",
";",
"++",
"j",
")",
"{",
"scanf",
"(",
"\"",
"\"",
",",
"&",
"token",
")",
";",
"datum",
"=",
"(",
"cell_t",
")",
"token",
";",
"community_init",
"[",
"i",
"]",
"[",
"j",
"]",
"=",
"datum",
";",
"}",
"}",
"printf",
"(",
"\"",
"\\n",
"\"",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
")",
";",
"for",
"(",
"size_t",
"i",
"=",
"0",
";",
"i",
"!=",
"config_K",
";",
"++",
"i",
")",
"{",
"for",
"(",
"size_t",
"j",
"=",
"0",
";",
"j",
"!=",
"config_L",
";",
"++",
"j",
")",
"{",
"transferCommunity",
"(",
"i",
",",
"j",
",",
"community_init",
")",
";",
"}",
"}",
"printf",
"(",
"\"",
"\\n",
"\"",
")",
";",
"}"
] | seed environment on a community-by-community basis,
from standard input; we assume that the seed input is exactly
the size of a community; 9999 indicates end of file;
run this before started ncurses environment; | [
"seed",
"environment",
"on",
"a",
"community",
"-",
"by",
"-",
"community",
"basis",
"from",
"standard",
"input",
";",
"we",
"assume",
"that",
"the",
"seed",
"input",
"is",
"exactly",
"the",
"size",
"of",
"a",
"community",
";",
"9999",
"indicates",
"end",
"of",
"file",
";",
"run",
"this",
"before",
"started",
"ncurses",
"environment",
";"
] | [
"// start by reading in a single community",
"// copy this community to each community in env to initialize it"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
46b8c05c537b4d686da58719c82968b051e8c3b9 | zrajani/Game_of_Life | Game of Life Project Files/source/cells.c | [
"MIT"
] | C | copyEnvironment | void | void copyEnvironment (void)
{
// copy this community to each community in env to initialize it
for (size_t i = 0; i != config_NE; ++i)
{
for (size_t j = 0; j != config_ME; ++j)
{
env[i][j] = update_env[i][j];
}
}
} | /*
* write changes to the environment, env, from update_env
*/ | write changes to the environment, env, from update_env | [
"write",
"changes",
"to",
"the",
"environment",
"env",
"from",
"update_env"
] | void copyEnvironment (void)
{
for (size_t i = 0; i != config_NE; ++i)
{
for (size_t j = 0; j != config_ME; ++j)
{
env[i][j] = update_env[i][j];
}
}
} | [
"void",
"copyEnvironment",
"(",
"void",
")",
"{",
"for",
"(",
"size_t",
"i",
"=",
"0",
";",
"i",
"!=",
"config_NE",
";",
"++",
"i",
")",
"{",
"for",
"(",
"size_t",
"j",
"=",
"0",
";",
"j",
"!=",
"config_ME",
";",
"++",
"j",
")",
"{",
"env",
"[",
"i",
"]",
"[",
"j",
"]",
"=",
"update_env",
"[",
"i",
"]",
"[",
"j",
"]",
";",
"}",
"}",
"}"
] | write changes to the environment, env, from update_env | [
"write",
"changes",
"to",
"the",
"environment",
"env",
"from",
"update_env"
] | [
"// copy this community to each community in env to initialize it"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
46b8c05c537b4d686da58719c82968b051e8c3b9 | zrajani/Game_of_Life | Game of Life Project Files/source/cells.c | [
"MIT"
] | C | updateCommFunc | void | void* updateCommFunc (void *param)
{
while (1)
{
if (reproduction_flag)
{
threadID_t *var = param;
size_t i_0 = var->row;
size_t j_0 = var->col;
size_t a = i_0 * config_NC;
size_t b = j_0 * config_MC;
for (size_t i = 0; i != config_NC; ++i)
{
for (size_t j = 0; j != config_MC; ++j)
{
updateCell (i+a, j+b);
}
}
}
}
} | /*
* this function updates all the cells for a thread (corresponding to one community)
*/ | this function updates all the cells for a thread (corresponding to one community) | [
"this",
"function",
"updates",
"all",
"the",
"cells",
"for",
"a",
"thread",
"(",
"corresponding",
"to",
"one",
"community",
")"
] | void* updateCommFunc (void *param)
{
while (1)
{
if (reproduction_flag)
{
threadID_t *var = param;
size_t i_0 = var->row;
size_t j_0 = var->col;
size_t a = i_0 * config_NC;
size_t b = j_0 * config_MC;
for (size_t i = 0; i != config_NC; ++i)
{
for (size_t j = 0; j != config_MC; ++j)
{
updateCell (i+a, j+b);
}
}
}
}
} | [
"void",
"*",
"updateCommFunc",
"(",
"void",
"*",
"param",
")",
"{",
"while",
"(",
"1",
")",
"{",
"if",
"(",
"reproduction_flag",
")",
"{",
"threadID_t",
"*",
"var",
"=",
"param",
";",
"size_t",
"i_0",
"=",
"var",
"->",
"row",
";",
"size_t",
"j_0",
"=",
"var",
"->",
"col",
";",
"size_t",
"a",
"=",
"i_0",
"*",
"config_NC",
";",
"size_t",
"b",
"=",
"j_0",
"*",
"config_MC",
";",
"for",
"(",
"size_t",
"i",
"=",
"0",
";",
"i",
"!=",
"config_NC",
";",
"++",
"i",
")",
"{",
"for",
"(",
"size_t",
"j",
"=",
"0",
";",
"j",
"!=",
"config_MC",
";",
"++",
"j",
")",
"{",
"updateCell",
"(",
"i",
"+",
"a",
",",
"j",
"+",
"b",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | this function updates all the cells for a thread (corresponding to one community) | [
"this",
"function",
"updates",
"all",
"the",
"cells",
"for",
"a",
"thread",
"(",
"corresponding",
"to",
"one",
"community",
")"
] | [] | [
{
"param": "param",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "param",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a47e3b3dd500225db60a4c367c3687497413467c | Afterback/Deadrop | engine/core/math/matrix4x4.h | [
"Zlib"
] | C | GetTranspose | Matrix4x4 | Matrix4x4 GetTranspose()
{
Matrix4x4 temp = {};
for (size_t i = 0; i < 4; i++)
{
for (size_t j = 0; j < 4; j++)
{
temp.mat[i][j] = mat[j][i];
}
}
return temp;
} | // returns the transpose of the matrix | returns the transpose of the matrix | [
"returns",
"the",
"transpose",
"of",
"the",
"matrix"
] | Matrix4x4 GetTranspose()
{
Matrix4x4 temp = {};
for (size_t i = 0; i < 4; i++)
{
for (size_t j = 0; j < 4; j++)
{
temp.mat[i][j] = mat[j][i];
}
}
return temp;
} | [
"Matrix4x4",
"GetTranspose",
"(",
")",
"{",
"Matrix4x4",
"temp",
"=",
"{",
"}",
";",
"for",
"(",
"size_t",
"i",
"=",
"0",
";",
"i",
"<",
"4",
";",
"i",
"++",
")",
"{",
"for",
"(",
"size_t",
"j",
"=",
"0",
";",
"j",
"<",
"4",
";",
"j",
"++",
")",
"{",
"temp",
".",
"mat",
"[",
"i",
"]",
"[",
"j",
"]",
"=",
"mat",
"[",
"j",
"]",
"[",
"i",
"]",
";",
"}",
"}",
"return",
"temp",
";",
"}"
] | returns the transpose of the matrix | [
"returns",
"the",
"transpose",
"of",
"the",
"matrix"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
137eeb80bad3c367df0bfe714500949c52014de9 | arthurfeeney/Marley-Accel | src/loading_util.c | [
"MIT"
] | C | load_config | int | int load_config(accel_settings_t *as, const char *config_path) {
FILE *config = fopen(config_path, "r");
char line[CONFIG_LINE_LENGTH];
while (fgets(line, sizeof(line), config) != NULL) {
make_lowercase(line);
remove_spaces(line);
remove_comments(line);
int err = assign_settings(line, as);
if (err) {
return err;
}
}
// default to quake accel if nothing specified.
if (!as->accel) {
as->accel = quake_accel;
}
fclose(config);
return 0;
} | /**
* Load users accel settings from the specified configuration file.
* This will automatically perform some cleaning to the config file and remove
* comments
*/ | Load users accel settings from the specified configuration file.
This will automatically perform some cleaning to the config file and remove
comments | [
"Load",
"users",
"accel",
"settings",
"from",
"the",
"specified",
"configuration",
"file",
".",
"This",
"will",
"automatically",
"perform",
"some",
"cleaning",
"to",
"the",
"config",
"file",
"and",
"remove",
"comments"
] | int load_config(accel_settings_t *as, const char *config_path) {
FILE *config = fopen(config_path, "r");
char line[CONFIG_LINE_LENGTH];
while (fgets(line, sizeof(line), config) != NULL) {
make_lowercase(line);
remove_spaces(line);
remove_comments(line);
int err = assign_settings(line, as);
if (err) {
return err;
}
}
if (!as->accel) {
as->accel = quake_accel;
}
fclose(config);
return 0;
} | [
"int",
"load_config",
"(",
"accel_settings_t",
"*",
"as",
",",
"const",
"char",
"*",
"config_path",
")",
"{",
"FILE",
"*",
"config",
"=",
"fopen",
"(",
"config_path",
",",
"\"",
"\"",
")",
";",
"char",
"line",
"[",
"CONFIG_LINE_LENGTH",
"]",
";",
"while",
"(",
"fgets",
"(",
"line",
",",
"sizeof",
"(",
"line",
")",
",",
"config",
")",
"!=",
"NULL",
")",
"{",
"make_lowercase",
"(",
"line",
")",
";",
"remove_spaces",
"(",
"line",
")",
";",
"remove_comments",
"(",
"line",
")",
";",
"int",
"err",
"=",
"assign_settings",
"(",
"line",
",",
"as",
")",
";",
"if",
"(",
"err",
")",
"{",
"return",
"err",
";",
"}",
"}",
"if",
"(",
"!",
"as",
"->",
"accel",
")",
"{",
"as",
"->",
"accel",
"=",
"quake_accel",
";",
"}",
"fclose",
"(",
"config",
")",
";",
"return",
"0",
";",
"}"
] | Load users accel settings from the specified configuration file. | [
"Load",
"users",
"accel",
"settings",
"from",
"the",
"specified",
"configuration",
"file",
"."
] | [
"// default to quake accel if nothing specified."
] | [
{
"param": "as",
"type": "accel_settings_t"
},
{
"param": "config_path",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "as",
"type": "accel_settings_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "config_path",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
137eeb80bad3c367df0bfe714500949c52014de9 | arthurfeeney/Marley-Accel | src/loading_util.c | [
"MIT"
] | C | dev_setup | int | int dev_setup(mouse_dev_t *dev) {
int err = libusb_init(&dev->usb_ctx);
if (err) {
return err;
}
// find the device using the vendor and product ids.
// These can be found using the "usb-devices" command in the terminal.
dev->usb_handle = libusb_open_device_with_vid_pid(
dev->usb_ctx, dev->vendor_id, dev->product_id);
if (!dev->usb_handle) {
printf("Marley-Accel: Device not found, try running with sudo.\n");
return -1;
}
// after an error, on restart the driver may not be attached. So,
// we make sure that it is attached.
// If driver is already attached, this has no effect.
libusb_attach_kernel_driver(dev->usb_handle, dev->interface);
if (libusb_kernel_driver_active(dev->usb_handle, dev->interface) == 1) {
err = libusb_detach_kernel_driver(dev->usb_handle, dev->interface);
if (err != 0) {
libusb_errmsg("Failed to detach kernel driver.\n", err);
return err;
}
dev->usb_detached = true;
} else {
printf("Marley-Accel: Device does not have an attached driver.\n");
printf("Marley-Accel: May not have been reattached after prior run.\n");
return -1;
}
if ((err = libusb_claim_interface(dev->usb_handle, dev->interface)) != 0) {
libusb_errmsg("Marley-Accel: Failed to claim device interface.\n", err);
return err;
}
dev->usb_claimed = true;
return 0;
} | /**
* Device setup. This connects to usb mouse device using libusb. Detaches the
* kernel driver and claims the device.
*/ | Device setup. This connects to usb mouse device using libusb. Detaches the
kernel driver and claims the device. | [
"Device",
"setup",
".",
"This",
"connects",
"to",
"usb",
"mouse",
"device",
"using",
"libusb",
".",
"Detaches",
"the",
"kernel",
"driver",
"and",
"claims",
"the",
"device",
"."
] | int dev_setup(mouse_dev_t *dev) {
int err = libusb_init(&dev->usb_ctx);
if (err) {
return err;
}
dev->usb_handle = libusb_open_device_with_vid_pid(
dev->usb_ctx, dev->vendor_id, dev->product_id);
if (!dev->usb_handle) {
printf("Marley-Accel: Device not found, try running with sudo.\n");
return -1;
}
libusb_attach_kernel_driver(dev->usb_handle, dev->interface);
if (libusb_kernel_driver_active(dev->usb_handle, dev->interface) == 1) {
err = libusb_detach_kernel_driver(dev->usb_handle, dev->interface);
if (err != 0) {
libusb_errmsg("Failed to detach kernel driver.\n", err);
return err;
}
dev->usb_detached = true;
} else {
printf("Marley-Accel: Device does not have an attached driver.\n");
printf("Marley-Accel: May not have been reattached after prior run.\n");
return -1;
}
if ((err = libusb_claim_interface(dev->usb_handle, dev->interface)) != 0) {
libusb_errmsg("Marley-Accel: Failed to claim device interface.\n", err);
return err;
}
dev->usb_claimed = true;
return 0;
} | [
"int",
"dev_setup",
"(",
"mouse_dev_t",
"*",
"dev",
")",
"{",
"int",
"err",
"=",
"libusb_init",
"(",
"&",
"dev",
"->",
"usb_ctx",
")",
";",
"if",
"(",
"err",
")",
"{",
"return",
"err",
";",
"}",
"dev",
"->",
"usb_handle",
"=",
"libusb_open_device_with_vid_pid",
"(",
"dev",
"->",
"usb_ctx",
",",
"dev",
"->",
"vendor_id",
",",
"dev",
"->",
"product_id",
")",
";",
"if",
"(",
"!",
"dev",
"->",
"usb_handle",
")",
"{",
"printf",
"(",
"\"",
"\\n",
"\"",
")",
";",
"return",
"-1",
";",
"}",
"libusb_attach_kernel_driver",
"(",
"dev",
"->",
"usb_handle",
",",
"dev",
"->",
"interface",
")",
";",
"if",
"(",
"libusb_kernel_driver_active",
"(",
"dev",
"->",
"usb_handle",
",",
"dev",
"->",
"interface",
")",
"==",
"1",
")",
"{",
"err",
"=",
"libusb_detach_kernel_driver",
"(",
"dev",
"->",
"usb_handle",
",",
"dev",
"->",
"interface",
")",
";",
"if",
"(",
"err",
"!=",
"0",
")",
"{",
"libusb_errmsg",
"(",
"\"",
"\\n",
"\"",
",",
"err",
")",
";",
"return",
"err",
";",
"}",
"dev",
"->",
"usb_detached",
"=",
"true",
";",
"}",
"else",
"{",
"printf",
"(",
"\"",
"\\n",
"\"",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
")",
";",
"return",
"-1",
";",
"}",
"if",
"(",
"(",
"err",
"=",
"libusb_claim_interface",
"(",
"dev",
"->",
"usb_handle",
",",
"dev",
"->",
"interface",
")",
")",
"!=",
"0",
")",
"{",
"libusb_errmsg",
"(",
"\"",
"\\n",
"\"",
",",
"err",
")",
";",
"return",
"err",
";",
"}",
"dev",
"->",
"usb_claimed",
"=",
"true",
";",
"return",
"0",
";",
"}"
] | Device setup. | [
"Device",
"setup",
"."
] | [
"// find the device using the vendor and product ids.",
"// These can be found using the \"usb-devices\" command in the terminal.",
"// after an error, on restart the driver may not be attached. So,",
"// we make sure that it is attached.",
"// If driver is already attached, this has no effect."
] | [
{
"param": "dev",
"type": "mouse_dev_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "mouse_dev_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
137eeb80bad3c367df0bfe714500949c52014de9 | arthurfeeney/Marley-Accel | src/loading_util.c | [
"MIT"
] | C | create_input_device | int | int create_input_device(uint16_t vendor_id, uint16_t product_id) {
int err;
const int fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
if (fd < 0) {
errmsg("Failed to open uinput", fd);
return fd;
}
create_bindings(fd);
err = initialize_device(fd, vendor_id, product_id);
if (err < 0) {
errmsg("Failed to write uinput device description", err);
return err;
}
err = ioctl(fd, UI_DEV_CREATE);
if (err < 0) {
errmsg("Failed to ioctl UI_DEV_CREATE", err);
return err;
}
return fd;
} | /**
* Creates uinput driver for the mouse with vendor_id and product_id.
* These values are part of the mouse settings.
*/ | Creates uinput driver for the mouse with vendor_id and product_id.
These values are part of the mouse settings. | [
"Creates",
"uinput",
"driver",
"for",
"the",
"mouse",
"with",
"vendor_id",
"and",
"product_id",
".",
"These",
"values",
"are",
"part",
"of",
"the",
"mouse",
"settings",
"."
] | int create_input_device(uint16_t vendor_id, uint16_t product_id) {
int err;
const int fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
if (fd < 0) {
errmsg("Failed to open uinput", fd);
return fd;
}
create_bindings(fd);
err = initialize_device(fd, vendor_id, product_id);
if (err < 0) {
errmsg("Failed to write uinput device description", err);
return err;
}
err = ioctl(fd, UI_DEV_CREATE);
if (err < 0) {
errmsg("Failed to ioctl UI_DEV_CREATE", err);
return err;
}
return fd;
} | [
"int",
"create_input_device",
"(",
"uint16_t",
"vendor_id",
",",
"uint16_t",
"product_id",
")",
"{",
"int",
"err",
";",
"const",
"int",
"fd",
"=",
"open",
"(",
"\"",
"\"",
",",
"O_WRONLY",
"|",
"O_NONBLOCK",
")",
";",
"if",
"(",
"fd",
"<",
"0",
")",
"{",
"errmsg",
"(",
"\"",
"\"",
",",
"fd",
")",
";",
"return",
"fd",
";",
"}",
"create_bindings",
"(",
"fd",
")",
";",
"err",
"=",
"initialize_device",
"(",
"fd",
",",
"vendor_id",
",",
"product_id",
")",
";",
"if",
"(",
"err",
"<",
"0",
")",
"{",
"errmsg",
"(",
"\"",
"\"",
",",
"err",
")",
";",
"return",
"err",
";",
"}",
"err",
"=",
"ioctl",
"(",
"fd",
",",
"UI_DEV_CREATE",
")",
";",
"if",
"(",
"err",
"<",
"0",
")",
"{",
"errmsg",
"(",
"\"",
"\"",
",",
"err",
")",
";",
"return",
"err",
";",
"}",
"return",
"fd",
";",
"}"
] | Creates uinput driver for the mouse with vendor_id and product_id. | [
"Creates",
"uinput",
"driver",
"for",
"the",
"mouse",
"with",
"vendor_id",
"and",
"product_id",
"."
] | [] | [
{
"param": "vendor_id",
"type": "uint16_t"
},
{
"param": "product_id",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "vendor_id",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "product_id",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
137eeb80bad3c367df0bfe714500949c52014de9 | arthurfeeney/Marley-Accel | src/loading_util.c | [
"MIT"
] | C | remove_spaces | void | static void remove_spaces(char *line) {
for (int idx = 0; idx < CONFIG_LINE_LENGTH && line[idx] != '\0'; ++idx) {
// shift text over to remove space.
if (isspace(line[idx])) {
for (int shift = idx; shift < CONFIG_LINE_LENGTH && line[shift] != '\0';
++shift) {
line[shift] = line[shift + 1];
}
}
}
} | /**
* Remove all spaces from the line string. The config files are small. This can
* be done efficiently enough by shifting text to cover spaces in-place.
*/ | Remove all spaces from the line string. The config files are small. This can
be done efficiently enough by shifting text to cover spaces in-place. | [
"Remove",
"all",
"spaces",
"from",
"the",
"line",
"string",
".",
"The",
"config",
"files",
"are",
"small",
".",
"This",
"can",
"be",
"done",
"efficiently",
"enough",
"by",
"shifting",
"text",
"to",
"cover",
"spaces",
"in",
"-",
"place",
"."
] | static void remove_spaces(char *line) {
for (int idx = 0; idx < CONFIG_LINE_LENGTH && line[idx] != '\0'; ++idx) {
if (isspace(line[idx])) {
for (int shift = idx; shift < CONFIG_LINE_LENGTH && line[shift] != '\0';
++shift) {
line[shift] = line[shift + 1];
}
}
}
} | [
"static",
"void",
"remove_spaces",
"(",
"char",
"*",
"line",
")",
"{",
"for",
"(",
"int",
"idx",
"=",
"0",
";",
"idx",
"<",
"CONFIG_LINE_LENGTH",
"&&",
"line",
"[",
"idx",
"]",
"!=",
"'",
"\\0",
"'",
";",
"++",
"idx",
")",
"{",
"if",
"(",
"isspace",
"(",
"line",
"[",
"idx",
"]",
")",
")",
"{",
"for",
"(",
"int",
"shift",
"=",
"idx",
";",
"shift",
"<",
"CONFIG_LINE_LENGTH",
"&&",
"line",
"[",
"shift",
"]",
"!=",
"'",
"\\0",
"'",
";",
"++",
"shift",
")",
"{",
"line",
"[",
"shift",
"]",
"=",
"line",
"[",
"shift",
"+",
"1",
"]",
";",
"}",
"}",
"}",
"}"
] | Remove all spaces from the line string. | [
"Remove",
"all",
"spaces",
"from",
"the",
"line",
"string",
"."
] | [
"// shift text over to remove space."
] | [
{
"param": "line",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "line",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
137eeb80bad3c367df0bfe714500949c52014de9 | arthurfeeney/Marley-Accel | src/loading_util.c | [
"MIT"
] | C | remove_comments | void | static void remove_comments(char *line) {
for (int idx = 0; idx < CONFIG_LINE_LENGTH; ++idx) {
if (line[idx] == '#') {
line[idx] = '\0';
}
}
} | /**
* Remove comments from a line in a config file
* This is done by Replace '#' with end of string.
*/ | Remove comments from a line in a config file
This is done by Replace '#' with end of string. | [
"Remove",
"comments",
"from",
"a",
"line",
"in",
"a",
"config",
"file",
"This",
"is",
"done",
"by",
"Replace",
"'",
"#",
"'",
"with",
"end",
"of",
"string",
"."
] | static void remove_comments(char *line) {
for (int idx = 0; idx < CONFIG_LINE_LENGTH; ++idx) {
if (line[idx] == '#') {
line[idx] = '\0';
}
}
} | [
"static",
"void",
"remove_comments",
"(",
"char",
"*",
"line",
")",
"{",
"for",
"(",
"int",
"idx",
"=",
"0",
";",
"idx",
"<",
"CONFIG_LINE_LENGTH",
";",
"++",
"idx",
")",
"{",
"if",
"(",
"line",
"[",
"idx",
"]",
"==",
"'",
"'",
")",
"{",
"line",
"[",
"idx",
"]",
"=",
"'",
"\\0",
"'",
";",
"}",
"}",
"}"
] | Remove comments from a line in a config file
This is done by Replace '#' with end of string. | [
"Remove",
"comments",
"from",
"a",
"line",
"in",
"a",
"config",
"file",
"This",
"is",
"done",
"by",
"Replace",
"'",
"#",
"'",
"with",
"end",
"of",
"string",
"."
] | [] | [
{
"param": "line",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "line",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c683559ae7122aa5be57f97af652ae02b580e006 | qq476743842/weex-saoa | platforms/ios/plus/Pods/SSLunarDate/SSLunarDate/libLunar.c | [
"MIT"
] | C | Solar2Day1 | null | long Solar2Day1(SSLunarSimpleDate *d)
{
long offset, delta;
int i;
delta = d->year - BYEAR;
if (delta<0) Error("Internal error: pick a larger constant for BYEAR.");
offset = delta * 365 + delta / 4 - delta / 100 + delta / 400;
for (i=1; i< d->month; i++)
offset += daysInSolarMonth[i];
if ((d->month > 2) && LeapYear(d->year))
offset++;
offset += d->day - 1;
if ((d->month == 2) && LeapYear(d->year))
{
if (d->day > 29) Error("Day out of range.");
}
else if (d->day > daysInSolarMonth[d->month]) Error("Day out of range.");
return offset;
} | /* Compute the number of days from the Solar date BYEAR.1.1 */ | Compute the number of days from the Solar date BYEAR.1.1 | [
"Compute",
"the",
"number",
"of",
"days",
"from",
"the",
"Solar",
"date",
"BYEAR",
".",
"1",
".",
"1"
] | long Solar2Day1(SSLunarSimpleDate *d)
{
long offset, delta;
int i;
delta = d->year - BYEAR;
if (delta<0) Error("Internal error: pick a larger constant for BYEAR.");
offset = delta * 365 + delta / 4 - delta / 100 + delta / 400;
for (i=1; i< d->month; i++)
offset += daysInSolarMonth[i];
if ((d->month > 2) && LeapYear(d->year))
offset++;
offset += d->day - 1;
if ((d->month == 2) && LeapYear(d->year))
{
if (d->day > 29) Error("Day out of range.");
}
else if (d->day > daysInSolarMonth[d->month]) Error("Day out of range.");
return offset;
} | [
"long",
"Solar2Day1",
"(",
"SSLunarSimpleDate",
"*",
"d",
")",
"{",
"long",
"offset",
",",
"delta",
";",
"int",
"i",
";",
"delta",
"=",
"d",
"->",
"year",
"-",
"BYEAR",
";",
"if",
"(",
"delta",
"<",
"0",
")",
"Error",
"(",
"\"",
"\"",
")",
";",
"offset",
"=",
"delta",
"*",
"365",
"+",
"delta",
"/",
"4",
"-",
"delta",
"/",
"100",
"+",
"delta",
"/",
"400",
";",
"for",
"(",
"i",
"=",
"1",
";",
"i",
"<",
"d",
"->",
"month",
";",
"i",
"++",
")",
"offset",
"+=",
"daysInSolarMonth",
"[",
"i",
"]",
";",
"if",
"(",
"(",
"d",
"->",
"month",
">",
"2",
")",
"&&",
"LeapYear",
"(",
"d",
"->",
"year",
")",
")",
"offset",
"++",
";",
"offset",
"+=",
"d",
"->",
"day",
"-",
"1",
";",
"if",
"(",
"(",
"d",
"->",
"month",
"==",
"2",
")",
"&&",
"LeapYear",
"(",
"d",
"->",
"year",
")",
")",
"{",
"if",
"(",
"d",
"->",
"day",
">",
"29",
")",
"Error",
"(",
"\"",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"d",
"->",
"day",
">",
"daysInSolarMonth",
"[",
"d",
"->",
"month",
"]",
")",
"Error",
"(",
"\"",
"\"",
")",
";",
"return",
"offset",
";",
"}"
] | Compute the number of days from the Solar date BYEAR.1.1 | [
"Compute",
"the",
"number",
"of",
"days",
"from",
"the",
"Solar",
"date",
"BYEAR",
".",
"1",
".",
"1"
] | [] | [
{
"param": "d",
"type": "SSLunarSimpleDate"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "d",
"type": "SSLunarSimpleDate",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c683559ae7122aa5be57f97af652ae02b580e006 | qq476743842/weex-saoa | platforms/ios/plus/Pods/SSLunarDate/SSLunarDate/libLunar.c | [
"MIT"
] | C | Lunar2Day | null | long Lunar2Day(LibLunarContext *ctx, SSLunarSimpleDate *d)
{
long offset = 0;
int year, i, m, leapMonth;
year = d->year - LunarFirstDate.year;
for (i=0; i<year; i++)
offset += ctx->_yday[i];
leapMonth = make_mday(ctx, year);
if ((d->leap) && (leapMonth!=d->month))
{
printf("%d is not a leap month in year %d.\n", d->month, d->year);
exit(1);
}
for (m=1; m<d->month; m++)
offset += ctx->_mday[m];
if (leapMonth &&
((d->month>leapMonth) || (d->leap && (d->month==leapMonth))))
offset += ctx->_mday[m++];
offset += d->day - 1;
if (d->day > ctx->_mday[m]) Error("Day out of range.");
return offset;
} | /* Compute offset days of a lunar date from the beginning of the table */ | Compute offset days of a lunar date from the beginning of the table | [
"Compute",
"offset",
"days",
"of",
"a",
"lunar",
"date",
"from",
"the",
"beginning",
"of",
"the",
"table"
] | long Lunar2Day(LibLunarContext *ctx, SSLunarSimpleDate *d)
{
long offset = 0;
int year, i, m, leapMonth;
year = d->year - LunarFirstDate.year;
for (i=0; i<year; i++)
offset += ctx->_yday[i];
leapMonth = make_mday(ctx, year);
if ((d->leap) && (leapMonth!=d->month))
{
printf("%d is not a leap month in year %d.\n", d->month, d->year);
exit(1);
}
for (m=1; m<d->month; m++)
offset += ctx->_mday[m];
if (leapMonth &&
((d->month>leapMonth) || (d->leap && (d->month==leapMonth))))
offset += ctx->_mday[m++];
offset += d->day - 1;
if (d->day > ctx->_mday[m]) Error("Day out of range.");
return offset;
} | [
"long",
"Lunar2Day",
"(",
"LibLunarContext",
"*",
"ctx",
",",
"SSLunarSimpleDate",
"*",
"d",
")",
"{",
"long",
"offset",
"=",
"0",
";",
"int",
"year",
",",
"i",
",",
"m",
",",
"leapMonth",
";",
"year",
"=",
"d",
"->",
"year",
"-",
"LunarFirstDate",
".",
"year",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"year",
";",
"i",
"++",
")",
"offset",
"+=",
"ctx",
"->",
"_yday",
"[",
"i",
"]",
";",
"leapMonth",
"=",
"make_mday",
"(",
"ctx",
",",
"year",
")",
";",
"if",
"(",
"(",
"d",
"->",
"leap",
")",
"&&",
"(",
"leapMonth",
"!=",
"d",
"->",
"month",
")",
")",
"{",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"d",
"->",
"month",
",",
"d",
"->",
"year",
")",
";",
"exit",
"(",
"1",
")",
";",
"}",
"for",
"(",
"m",
"=",
"1",
";",
"m",
"<",
"d",
"->",
"month",
";",
"m",
"++",
")",
"offset",
"+=",
"ctx",
"->",
"_mday",
"[",
"m",
"]",
";",
"if",
"(",
"leapMonth",
"&&",
"(",
"(",
"d",
"->",
"month",
">",
"leapMonth",
")",
"||",
"(",
"d",
"->",
"leap",
"&&",
"(",
"d",
"->",
"month",
"==",
"leapMonth",
")",
")",
")",
")",
"offset",
"+=",
"ctx",
"->",
"_mday",
"[",
"m",
"++",
"]",
";",
"offset",
"+=",
"d",
"->",
"day",
"-",
"1",
";",
"if",
"(",
"d",
"->",
"day",
">",
"ctx",
"->",
"_mday",
"[",
"m",
"]",
")",
"Error",
"(",
"\"",
"\"",
")",
";",
"return",
"offset",
";",
"}"
] | Compute offset days of a lunar date from the beginning of the table | [
"Compute",
"offset",
"days",
"of",
"a",
"lunar",
"date",
"from",
"the",
"beginning",
"of",
"the",
"table"
] | [] | [
{
"param": "ctx",
"type": "LibLunarContext"
},
{
"param": "d",
"type": "SSLunarSimpleDate"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ctx",
"type": "LibLunarContext",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d",
"type": "SSLunarSimpleDate",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c683559ae7122aa5be57f97af652ae02b580e006 | qq476743842/weex-saoa | platforms/ios/plus/Pods/SSLunarDate/SSLunarDate/libLunar.c | [
"MIT"
] | C | JieDate | int | int JieDate(SSLunarSimpleDate *ds, SSLunarSimpleDate *dl)
{
int m, flag;
if (ds->month==1)
{
flag = CmpDate(ds->month, ds->day,
1, fest[ds->year - SolarFirstDate.year - 1][11]);
if (flag<0) dl->month = 11;
else if (flag>0) dl->month = 12;
dl->year = ds->year - 1;
return(flag==0);
}
for (m=2; m<=12; m++)
{
flag = CmpDate(ds->month, ds->day,
m, fest[ds->year - SolarFirstDate.year][m-2]);
if (flag==0) m++;
if (flag<=0) break;
}
dl->month = (m-2) % 12;
dl->year = ds->year;
if ((dl->month)==0)
{
dl->year = ds->year - 1;
dl->month = 12;
}
return(flag==0);
} | /*
Given a solar date, find the "lunar" date for the purpose of
calculating the "4-columns" by taking jie into consideration.
*/ | Given a solar date, find the "lunar" date for the purpose of
calculating the "4-columns" by taking jie into consideration. | [
"Given",
"a",
"solar",
"date",
"find",
"the",
"\"",
"lunar",
"\"",
"date",
"for",
"the",
"purpose",
"of",
"calculating",
"the",
"\"",
"4",
"-",
"columns",
"\"",
"by",
"taking",
"jie",
"into",
"consideration",
"."
] | int JieDate(SSLunarSimpleDate *ds, SSLunarSimpleDate *dl)
{
int m, flag;
if (ds->month==1)
{
flag = CmpDate(ds->month, ds->day,
1, fest[ds->year - SolarFirstDate.year - 1][11]);
if (flag<0) dl->month = 11;
else if (flag>0) dl->month = 12;
dl->year = ds->year - 1;
return(flag==0);
}
for (m=2; m<=12; m++)
{
flag = CmpDate(ds->month, ds->day,
m, fest[ds->year - SolarFirstDate.year][m-2]);
if (flag==0) m++;
if (flag<=0) break;
}
dl->month = (m-2) % 12;
dl->year = ds->year;
if ((dl->month)==0)
{
dl->year = ds->year - 1;
dl->month = 12;
}
return(flag==0);
} | [
"int",
"JieDate",
"(",
"SSLunarSimpleDate",
"*",
"ds",
",",
"SSLunarSimpleDate",
"*",
"dl",
")",
"{",
"int",
"m",
",",
"flag",
";",
"if",
"(",
"ds",
"->",
"month",
"==",
"1",
")",
"{",
"flag",
"=",
"CmpDate",
"(",
"ds",
"->",
"month",
",",
"ds",
"->",
"day",
",",
"1",
",",
"fest",
"[",
"ds",
"->",
"year",
"-",
"SolarFirstDate",
".",
"year",
"-",
"1",
"]",
"[",
"11",
"]",
")",
";",
"if",
"(",
"flag",
"<",
"0",
")",
"dl",
"->",
"month",
"=",
"11",
";",
"else",
"if",
"(",
"flag",
">",
"0",
")",
"dl",
"->",
"month",
"=",
"12",
";",
"dl",
"->",
"year",
"=",
"ds",
"->",
"year",
"-",
"1",
";",
"return",
"(",
"flag",
"==",
"0",
")",
";",
"}",
"for",
"(",
"m",
"=",
"2",
";",
"m",
"<=",
"12",
";",
"m",
"++",
")",
"{",
"flag",
"=",
"CmpDate",
"(",
"ds",
"->",
"month",
",",
"ds",
"->",
"day",
",",
"m",
",",
"fest",
"[",
"ds",
"->",
"year",
"-",
"SolarFirstDate",
".",
"year",
"]",
"[",
"m",
"-",
"2",
"]",
")",
";",
"if",
"(",
"flag",
"==",
"0",
")",
"m",
"++",
";",
"if",
"(",
"flag",
"<=",
"0",
")",
"break",
";",
"}",
"dl",
"->",
"month",
"=",
"(",
"m",
"-",
"2",
")",
"%",
"12",
";",
"dl",
"->",
"year",
"=",
"ds",
"->",
"year",
";",
"if",
"(",
"(",
"dl",
"->",
"month",
")",
"==",
"0",
")",
"{",
"dl",
"->",
"year",
"=",
"ds",
"->",
"year",
"-",
"1",
";",
"dl",
"->",
"month",
"=",
"12",
";",
"}",
"return",
"(",
"flag",
"==",
"0",
")",
";",
"}"
] | Given a solar date, find the "lunar" date for the purpose of
calculating the "4-columns" by taking jie into consideration. | [
"Given",
"a",
"solar",
"date",
"find",
"the",
"\"",
"lunar",
"\"",
"date",
"for",
"the",
"purpose",
"of",
"calculating",
"the",
"\"",
"4",
"-",
"columns",
"\"",
"by",
"taking",
"jie",
"into",
"consideration",
"."
] | [] | [
{
"param": "ds",
"type": "SSLunarSimpleDate"
},
{
"param": "dl",
"type": "SSLunarSimpleDate"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ds",
"type": "SSLunarSimpleDate",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dl",
"type": "SSLunarSimpleDate",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c683559ae7122aa5be57f97af652ae02b580e006 | qq476743842/weex-saoa | platforms/ios/plus/Pods/SSLunarDate/SSLunarDate/libLunar.c | [
"MIT"
] | C | make_yday | int | int make_yday(LibLunarContext *ctx)
{
int year, i, leap;
long code;
for (year = 0; year < Nyear; year++)
{
code = yearInfo[year];
leap = code & 0xf;
ctx->_yday[year] = 0;
if (leap != 0)
{
i = (code >> 16) & 0x1;
ctx->_yday[year] += moon[i];
/* Big month or small month.... got it. Leap month only
* have two day, big month or small month. */
}
code >>= 4;
for (i = 0; i < Nmonth-1; i++)
{
/* 12 months. */
ctx->_yday[year] += moon[code&0x1];
code >>= 1;
}
ctx->_ymonth[year] = 12;
if (leap != 0) ctx->_ymonth[year]++;
}
return Nyear;
} | /* Compute the number of days in each lunar year in the table */ | Compute the number of days in each lunar year in the table | [
"Compute",
"the",
"number",
"of",
"days",
"in",
"each",
"lunar",
"year",
"in",
"the",
"table"
] | int make_yday(LibLunarContext *ctx)
{
int year, i, leap;
long code;
for (year = 0; year < Nyear; year++)
{
code = yearInfo[year];
leap = code & 0xf;
ctx->_yday[year] = 0;
if (leap != 0)
{
i = (code >> 16) & 0x1;
ctx->_yday[year] += moon[i];
}
code >>= 4;
for (i = 0; i < Nmonth-1; i++)
{
ctx->_yday[year] += moon[code&0x1];
code >>= 1;
}
ctx->_ymonth[year] = 12;
if (leap != 0) ctx->_ymonth[year]++;
}
return Nyear;
} | [
"int",
"make_yday",
"(",
"LibLunarContext",
"*",
"ctx",
")",
"{",
"int",
"year",
",",
"i",
",",
"leap",
";",
"long",
"code",
";",
"for",
"(",
"year",
"=",
"0",
";",
"year",
"<",
"Nyear",
";",
"year",
"++",
")",
"{",
"code",
"=",
"yearInfo",
"[",
"year",
"]",
";",
"leap",
"=",
"code",
"&",
"0xf",
";",
"ctx",
"->",
"_yday",
"[",
"year",
"]",
"=",
"0",
";",
"if",
"(",
"leap",
"!=",
"0",
")",
"{",
"i",
"=",
"(",
"code",
">>",
"16",
")",
"&",
"0x1",
";",
"ctx",
"->",
"_yday",
"[",
"year",
"]",
"+=",
"moon",
"[",
"i",
"]",
";",
"}",
"code",
">>=",
"4",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"Nmonth",
"-",
"1",
";",
"i",
"++",
")",
"{",
"ctx",
"->",
"_yday",
"[",
"year",
"]",
"+=",
"moon",
"[",
"code",
"&",
"0x1",
"]",
";",
"code",
">>=",
"1",
";",
"}",
"ctx",
"->",
"_ymonth",
"[",
"year",
"]",
"=",
"12",
";",
"if",
"(",
"leap",
"!=",
"0",
")",
"ctx",
"->",
"_ymonth",
"[",
"year",
"]",
"++",
";",
"}",
"return",
"Nyear",
";",
"}"
] | Compute the number of days in each lunar year in the table | [
"Compute",
"the",
"number",
"of",
"days",
"in",
"each",
"lunar",
"year",
"in",
"the",
"table"
] | [
"/* Big month or small month.... got it. Leap month only\n * have two day, big month or small month. */",
"/* 12 months. */"
] | [
{
"param": "ctx",
"type": "LibLunarContext"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ctx",
"type": "LibLunarContext",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c683559ae7122aa5be57f97af652ae02b580e006 | qq476743842/weex-saoa | platforms/ios/plus/Pods/SSLunarDate/SSLunarDate/libLunar.c | [
"MIT"
] | C | make_mday | int | int make_mday(LibLunarContext *ctx, int year)
{
int i, leapMonth;
long code;
code = yearInfo[year];
leapMonth = code & 0xf;
/* leapMonth == 0 means no leap month */
code >>= 4;
if (leapMonth == 0)
{
ctx->_mday[Nmonth] = 0;
for (i = Nmonth-1; i >= 1; i--)
{
ctx->_mday[i] = moon[code&0x1];
code >>= 1;
}
}
else
{
/*
There is a leap month (run4 yue4) L in this year.
mday[1] contains the number of days in the 1-st month;
mday[L] contains the number of days in the L-th month;
mday[L+1] contains the number of days in the L-th leap month;
mday[L+2] contains the number of days in the L+1 month, etc.
cf. yearInfo[]: info about the leap month is encoded differently.
*/
i = (yearInfo[year] >> 16) & 0x1;
ctx->_mday[leapMonth+1] = moon[i];
for (i = Nmonth; i >= 1; i--)
{
if (i == leapMonth+1)
i--;
ctx->_mday[i] = moon[code&0x1];
code >>= 1;
}
}
return leapMonth;
} | /* Compute the days of each month in the given lunar year */ | Compute the days of each month in the given lunar year | [
"Compute",
"the",
"days",
"of",
"each",
"month",
"in",
"the",
"given",
"lunar",
"year"
] | int make_mday(LibLunarContext *ctx, int year)
{
int i, leapMonth;
long code;
code = yearInfo[year];
leapMonth = code & 0xf;
code >>= 4;
if (leapMonth == 0)
{
ctx->_mday[Nmonth] = 0;
for (i = Nmonth-1; i >= 1; i--)
{
ctx->_mday[i] = moon[code&0x1];
code >>= 1;
}
}
else
{
i = (yearInfo[year] >> 16) & 0x1;
ctx->_mday[leapMonth+1] = moon[i];
for (i = Nmonth; i >= 1; i--)
{
if (i == leapMonth+1)
i--;
ctx->_mday[i] = moon[code&0x1];
code >>= 1;
}
}
return leapMonth;
} | [
"int",
"make_mday",
"(",
"LibLunarContext",
"*",
"ctx",
",",
"int",
"year",
")",
"{",
"int",
"i",
",",
"leapMonth",
";",
"long",
"code",
";",
"code",
"=",
"yearInfo",
"[",
"year",
"]",
";",
"leapMonth",
"=",
"code",
"&",
"0xf",
";",
"code",
">>=",
"4",
";",
"if",
"(",
"leapMonth",
"==",
"0",
")",
"{",
"ctx",
"->",
"_mday",
"[",
"Nmonth",
"]",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"Nmonth",
"-",
"1",
";",
"i",
">=",
"1",
";",
"i",
"--",
")",
"{",
"ctx",
"->",
"_mday",
"[",
"i",
"]",
"=",
"moon",
"[",
"code",
"&",
"0x1",
"]",
";",
"code",
">>=",
"1",
";",
"}",
"}",
"else",
"{",
"i",
"=",
"(",
"yearInfo",
"[",
"year",
"]",
">>",
"16",
")",
"&",
"0x1",
";",
"ctx",
"->",
"_mday",
"[",
"leapMonth",
"+",
"1",
"]",
"=",
"moon",
"[",
"i",
"]",
";",
"for",
"(",
"i",
"=",
"Nmonth",
";",
"i",
">=",
"1",
";",
"i",
"--",
")",
"{",
"if",
"(",
"i",
"==",
"leapMonth",
"+",
"1",
")",
"i",
"--",
";",
"ctx",
"->",
"_mday",
"[",
"i",
"]",
"=",
"moon",
"[",
"code",
"&",
"0x1",
"]",
";",
"code",
">>=",
"1",
";",
"}",
"}",
"return",
"leapMonth",
";",
"}"
] | Compute the days of each month in the given lunar year | [
"Compute",
"the",
"days",
"of",
"each",
"month",
"in",
"the",
"given",
"lunar",
"year"
] | [
"/* leapMonth == 0 means no leap month */",
"/*\n There is a leap month (run4 yue4) L in this year.\n mday[1] contains the number of days in the 1-st month;\n mday[L] contains the number of days in the L-th month;\n mday[L+1] contains the number of days in the L-th leap month;\n mday[L+2] contains the number of days in the L+1 month, etc.\n \n cf. yearInfo[]: info about the leap month is encoded differently.\n */"
] | [
{
"param": "ctx",
"type": "LibLunarContext"
},
{
"param": "year",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ctx",
"type": "LibLunarContext",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "year",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6be0195c32779659db3aca6d6faa5b83c160c820 | scizzorz/rain | rain/base/regex/regex.c | [
"BSD-2-Clause",
"MIT"
] | C | table_from_matches | void | void table_from_matches(box *table, const char *matched, int *ovector, int pcre_exec_ret) {
const char *match;
box key;
box val;
rain_set_str(&key, "count");
rain_set_int(&val, pcre_exec_ret);
rain_put(table, &key, &val);
for(int i = 0; i < pcre_exec_ret; ++i) {
pcre_get_substring(matched, ovector, pcre_exec_ret, i, &match);
rain_set_int(&key, i);
rain_set_strcpy(&val, match, strlen(match));
rain_put(table, &key, &val);
pcre_free_substring(match);
}
} | /* proof of concept regular expression library */ | proof of concept regular expression library | [
"proof",
"of",
"concept",
"regular",
"expression",
"library"
] | void table_from_matches(box *table, const char *matched, int *ovector, int pcre_exec_ret) {
const char *match;
box key;
box val;
rain_set_str(&key, "count");
rain_set_int(&val, pcre_exec_ret);
rain_put(table, &key, &val);
for(int i = 0; i < pcre_exec_ret; ++i) {
pcre_get_substring(matched, ovector, pcre_exec_ret, i, &match);
rain_set_int(&key, i);
rain_set_strcpy(&val, match, strlen(match));
rain_put(table, &key, &val);
pcre_free_substring(match);
}
} | [
"void",
"table_from_matches",
"(",
"box",
"*",
"table",
",",
"const",
"char",
"*",
"matched",
",",
"int",
"*",
"ovector",
",",
"int",
"pcre_exec_ret",
")",
"{",
"const",
"char",
"*",
"match",
";",
"box",
"key",
";",
"box",
"val",
";",
"rain_set_str",
"(",
"&",
"key",
",",
"\"",
"\"",
")",
";",
"rain_set_int",
"(",
"&",
"val",
",",
"pcre_exec_ret",
")",
";",
"rain_put",
"(",
"table",
",",
"&",
"key",
",",
"&",
"val",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"pcre_exec_ret",
";",
"++",
"i",
")",
"{",
"pcre_get_substring",
"(",
"matched",
",",
"ovector",
",",
"pcre_exec_ret",
",",
"i",
",",
"&",
"match",
")",
";",
"rain_set_int",
"(",
"&",
"key",
",",
"i",
")",
";",
"rain_set_strcpy",
"(",
"&",
"val",
",",
"match",
",",
"strlen",
"(",
"match",
")",
")",
";",
"rain_put",
"(",
"table",
",",
"&",
"key",
",",
"&",
"val",
")",
";",
"pcre_free_substring",
"(",
"match",
")",
";",
"}",
"}"
] | proof of concept regular expression library | [
"proof",
"of",
"concept",
"regular",
"expression",
"library"
] | [] | [
{
"param": "table",
"type": "box"
},
{
"param": "matched",
"type": "char"
},
{
"param": "ovector",
"type": "int"
},
{
"param": "pcre_exec_ret",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "table",
"type": "box",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "matched",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ovector",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pcre_exec_ret",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4be490ea4f4b253bfa7978d4e82d4619700e3ff1 | FLira2000/String | String.c | [
"MIT"
] | C | stringLength | int | int stringLength(String *string){
int i = 0;
for(i; string->stuff[i] != '\0'; i++);
return i;
} | //Count the length of a string inside the object String. Access the 'stuff' member. | Count the length of a string inside the object String. Access the 'stuff' member. | [
"Count",
"the",
"length",
"of",
"a",
"string",
"inside",
"the",
"object",
"String",
".",
"Access",
"the",
"'",
"stuff",
"'",
"member",
"."
] | int stringLength(String *string){
int i = 0;
for(i; string->stuff[i] != '\0'; i++);
return i;
} | [
"int",
"stringLength",
"(",
"String",
"*",
"string",
")",
"{",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"i",
";",
"string",
"->",
"stuff",
"[",
"i",
"]",
"!=",
"'",
"\\0",
"'",
";",
"i",
"++",
")",
";",
"return",
"i",
";",
"}"
] | Count the length of a string inside the object String. | [
"Count",
"the",
"length",
"of",
"a",
"string",
"inside",
"the",
"object",
"String",
"."
] | [] | [
{
"param": "string",
"type": "String"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "string",
"type": "String",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4be490ea4f4b253bfa7978d4e82d4619700e3ff1 | FLira2000/String | String.c | [
"MIT"
] | C | forEach | void | void forEach( String *string, void (*lambda)( void ) ){
int i = 0;
for(i; string->stuff[i] != '\0'; i++){
lambda();
}
} | //Expects a function without parameters to be executed each character inside the string. | Expects a function without parameters to be executed each character inside the string. | [
"Expects",
"a",
"function",
"without",
"parameters",
"to",
"be",
"executed",
"each",
"character",
"inside",
"the",
"string",
"."
] | void forEach( String *string, void (*lambda)( void ) ){
int i = 0;
for(i; string->stuff[i] != '\0'; i++){
lambda();
}
} | [
"void",
"forEach",
"(",
"String",
"*",
"string",
",",
"void",
"(",
"*",
"lambda",
")",
"(",
"void",
")",
")",
"{",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"i",
";",
"string",
"->",
"stuff",
"[",
"i",
"]",
"!=",
"'",
"\\0",
"'",
";",
"i",
"++",
")",
"{",
"lambda",
"(",
")",
";",
"}",
"}"
] | Expects a function without parameters to be executed each character inside the string. | [
"Expects",
"a",
"function",
"without",
"parameters",
"to",
"be",
"executed",
"each",
"character",
"inside",
"the",
"string",
"."
] | [] | [
{
"param": "string",
"type": "String"
},
{
"param": "lambda",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "string",
"type": "String",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lambda",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4be490ea4f4b253bfa7978d4e82d4619700e3ff1 | FLira2000/String | String.c | [
"MIT"
] | C | searchFor | int | int searchFor( String *string, char* searching ) {
int i = 0; int condition = localLength(searching);
for(i; string->stuff[i] != '\0'; i++){
if( searching[0] == string->stuff[i] ){
condition--;
for( int y = 1; searching[y] != '\0'; y++ ){
if( searching[y] == '\0') break;
else if( searching[y] == string->stuff[i + y] ){
condition--;
continue;
}else{
condition = localLength(searching);
break;
}
}
if(condition == 0) return 1;
}
}
return 0;
} | //Receives the String object and a char array, and searches inside the 'stuff' member of the object for the char array. | Receives the String object and a char array, and searches inside the 'stuff' member of the object for the char array. | [
"Receives",
"the",
"String",
"object",
"and",
"a",
"char",
"array",
"and",
"searches",
"inside",
"the",
"'",
"stuff",
"'",
"member",
"of",
"the",
"object",
"for",
"the",
"char",
"array",
"."
] | int searchFor( String *string, char* searching ) {
int i = 0; int condition = localLength(searching);
for(i; string->stuff[i] != '\0'; i++){
if( searching[0] == string->stuff[i] ){
condition--;
for( int y = 1; searching[y] != '\0'; y++ ){
if( searching[y] == '\0') break;
else if( searching[y] == string->stuff[i + y] ){
condition--;
continue;
}else{
condition = localLength(searching);
break;
}
}
if(condition == 0) return 1;
}
}
return 0;
} | [
"int",
"searchFor",
"(",
"String",
"*",
"string",
",",
"char",
"*",
"searching",
")",
"{",
"int",
"i",
"=",
"0",
";",
"int",
"condition",
"=",
"localLength",
"(",
"searching",
")",
";",
"for",
"(",
"i",
";",
"string",
"->",
"stuff",
"[",
"i",
"]",
"!=",
"'",
"\\0",
"'",
";",
"i",
"++",
")",
"{",
"if",
"(",
"searching",
"[",
"0",
"]",
"==",
"string",
"->",
"stuff",
"[",
"i",
"]",
")",
"{",
"condition",
"--",
";",
"for",
"(",
"int",
"y",
"=",
"1",
";",
"searching",
"[",
"y",
"]",
"!=",
"'",
"\\0",
"'",
";",
"y",
"++",
")",
"{",
"if",
"(",
"searching",
"[",
"y",
"]",
"==",
"'",
"\\0",
"'",
")",
"break",
";",
"else",
"if",
"(",
"searching",
"[",
"y",
"]",
"==",
"string",
"->",
"stuff",
"[",
"i",
"+",
"y",
"]",
")",
"{",
"condition",
"--",
";",
"continue",
";",
"}",
"else",
"{",
"condition",
"=",
"localLength",
"(",
"searching",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"condition",
"==",
"0",
")",
"return",
"1",
";",
"}",
"}",
"return",
"0",
";",
"}"
] | Receives the String object and a char array, and searches inside the 'stuff' member of the object for the char array. | [
"Receives",
"the",
"String",
"object",
"and",
"a",
"char",
"array",
"and",
"searches",
"inside",
"the",
"'",
"stuff",
"'",
"member",
"of",
"the",
"object",
"for",
"the",
"char",
"array",
"."
] | [] | [
{
"param": "string",
"type": "String"
},
{
"param": "searching",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "string",
"type": "String",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "searching",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4be490ea4f4b253bfa7978d4e82d4619700e3ff1 | FLira2000/String | String.c | [
"MIT"
] | C | isNull | int | int isNull( String *string ){
if(string == NULL){
return 1;
}
if(string->stuff == NULL){
return 1;
}
return 0;
} | //Return 1 if the pointer is NULL. 0 if not. | Return 1 if the pointer is NULL. 0 if not. | [
"Return",
"1",
"if",
"the",
"pointer",
"is",
"NULL",
".",
"0",
"if",
"not",
"."
] | int isNull( String *string ){
if(string == NULL){
return 1;
}
if(string->stuff == NULL){
return 1;
}
return 0;
} | [
"int",
"isNull",
"(",
"String",
"*",
"string",
")",
"{",
"if",
"(",
"string",
"==",
"NULL",
")",
"{",
"return",
"1",
";",
"}",
"if",
"(",
"string",
"->",
"stuff",
"==",
"NULL",
")",
"{",
"return",
"1",
";",
"}",
"return",
"0",
";",
"}"
] | Return 1 if the pointer is NULL. | [
"Return",
"1",
"if",
"the",
"pointer",
"is",
"NULL",
"."
] | [] | [
{
"param": "string",
"type": "String"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "string",
"type": "String",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4be490ea4f4b253bfa7978d4e82d4619700e3ff1 | FLira2000/String | String.c | [
"MIT"
] | C | isEqual | int | int isEqual( String *string1, char *string2 ){
int i = 0;
if(string1->length(string1->self) != localLength(string2)) return 0;
for(i; string1->stuff[i] != '\0'; i++){
if(string1->stuff[i] != string2[i]) return 0;
}
return 1;
} | //Receives the String object itself, and a char array, to compare then. Returns 1 if they are equal, or 0 if not. | Receives the String object itself, and a char array, to compare then. Returns 1 if they are equal, or 0 if not. | [
"Receives",
"the",
"String",
"object",
"itself",
"and",
"a",
"char",
"array",
"to",
"compare",
"then",
".",
"Returns",
"1",
"if",
"they",
"are",
"equal",
"or",
"0",
"if",
"not",
"."
] | int isEqual( String *string1, char *string2 ){
int i = 0;
if(string1->length(string1->self) != localLength(string2)) return 0;
for(i; string1->stuff[i] != '\0'; i++){
if(string1->stuff[i] != string2[i]) return 0;
}
return 1;
} | [
"int",
"isEqual",
"(",
"String",
"*",
"string1",
",",
"char",
"*",
"string2",
")",
"{",
"int",
"i",
"=",
"0",
";",
"if",
"(",
"string1",
"->",
"length",
"(",
"string1",
"->",
"self",
")",
"!=",
"localLength",
"(",
"string2",
")",
")",
"return",
"0",
";",
"for",
"(",
"i",
";",
"string1",
"->",
"stuff",
"[",
"i",
"]",
"!=",
"'",
"\\0",
"'",
";",
"i",
"++",
")",
"{",
"if",
"(",
"string1",
"->",
"stuff",
"[",
"i",
"]",
"!=",
"string2",
"[",
"i",
"]",
")",
"return",
"0",
";",
"}",
"return",
"1",
";",
"}"
] | Receives the String object itself, and a char array, to compare then. | [
"Receives",
"the",
"String",
"object",
"itself",
"and",
"a",
"char",
"array",
"to",
"compare",
"then",
"."
] | [] | [
{
"param": "string1",
"type": "String"
},
{
"param": "string2",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "string1",
"type": "String",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "string2",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4be490ea4f4b253bfa7978d4e82d4619700e3ff1 | FLira2000/String | String.c | [
"MIT"
] | C | concat | void | void concat( String *toReceive, String *toAdd){
int newSize = (toReceive->length(toReceive->self));
newSize+= toAdd->length(toAdd->self);
char *newP = (char*) calloc(sizeof(char), newSize);
int i = 0;
for(i; i < toReceive->length(toReceive->self); i++){
if(toReceive->stuff[i] != '\0')
newP[i] = toReceive->stuff[i];
}
for(i; (i - toReceive->length(toReceive->self)) < toAdd->length(toAdd->self); i++){
newP[i] = toAdd->stuff[i - toReceive->length(toReceive->self)];
}
toReceive->stuff = newP;
} | //Concatenate a string to another. | Concatenate a string to another. | [
"Concatenate",
"a",
"string",
"to",
"another",
"."
] | void concat( String *toReceive, String *toAdd){
int newSize = (toReceive->length(toReceive->self));
newSize+= toAdd->length(toAdd->self);
char *newP = (char*) calloc(sizeof(char), newSize);
int i = 0;
for(i; i < toReceive->length(toReceive->self); i++){
if(toReceive->stuff[i] != '\0')
newP[i] = toReceive->stuff[i];
}
for(i; (i - toReceive->length(toReceive->self)) < toAdd->length(toAdd->self); i++){
newP[i] = toAdd->stuff[i - toReceive->length(toReceive->self)];
}
toReceive->stuff = newP;
} | [
"void",
"concat",
"(",
"String",
"*",
"toReceive",
",",
"String",
"*",
"toAdd",
")",
"{",
"int",
"newSize",
"=",
"(",
"toReceive",
"->",
"length",
"(",
"toReceive",
"->",
"self",
")",
")",
";",
"newSize",
"+=",
"toAdd",
"->",
"length",
"(",
"toAdd",
"->",
"self",
")",
";",
"char",
"*",
"newP",
"=",
"(",
"char",
"*",
")",
"calloc",
"(",
"sizeof",
"(",
"char",
")",
",",
"newSize",
")",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"i",
";",
"i",
"<",
"toReceive",
"->",
"length",
"(",
"toReceive",
"->",
"self",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"toReceive",
"->",
"stuff",
"[",
"i",
"]",
"!=",
"'",
"\\0",
"'",
")",
"newP",
"[",
"i",
"]",
"=",
"toReceive",
"->",
"stuff",
"[",
"i",
"]",
";",
"}",
"for",
"(",
"i",
";",
"(",
"i",
"-",
"toReceive",
"->",
"length",
"(",
"toReceive",
"->",
"self",
")",
")",
"<",
"toAdd",
"->",
"length",
"(",
"toAdd",
"->",
"self",
")",
";",
"i",
"++",
")",
"{",
"newP",
"[",
"i",
"]",
"=",
"toAdd",
"->",
"stuff",
"[",
"i",
"-",
"toReceive",
"->",
"length",
"(",
"toReceive",
"->",
"self",
")",
"]",
";",
"}",
"toReceive",
"->",
"stuff",
"=",
"newP",
";",
"}"
] | Concatenate a string to another. | [
"Concatenate",
"a",
"string",
"to",
"another",
"."
] | [] | [
{
"param": "toReceive",
"type": "String"
},
{
"param": "toAdd",
"type": "String"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "toReceive",
"type": "String",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "toAdd",
"type": "String",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4be490ea4f4b253bfa7978d4e82d4619700e3ff1 | FLira2000/String | String.c | [
"MIT"
] | C | newString | String | String* newString( char *string ){
String *s = (String*) malloc(sizeof(String));
s->stuff = string;
s->self = s;
s->length = &stringLength;
s->forEach = &forEach;
s->searchFor = &searchFor;
s->isBlank = &isBlank;
s->isEqual = &isEqual;
s->concat = &concat;
s->setString = &setString;
s->exportString = &exportString;
return s;
} | //Constructor. Receives the stuff in characters to fill the object that will be created. | Constructor. Receives the stuff in characters to fill the object that will be created. | [
"Constructor",
".",
"Receives",
"the",
"stuff",
"in",
"characters",
"to",
"fill",
"the",
"object",
"that",
"will",
"be",
"created",
"."
] | String* newString( char *string ){
String *s = (String*) malloc(sizeof(String));
s->stuff = string;
s->self = s;
s->length = &stringLength;
s->forEach = &forEach;
s->searchFor = &searchFor;
s->isBlank = &isBlank;
s->isEqual = &isEqual;
s->concat = &concat;
s->setString = &setString;
s->exportString = &exportString;
return s;
} | [
"String",
"*",
"newString",
"(",
"char",
"*",
"string",
")",
"{",
"String",
"*",
"s",
"=",
"(",
"String",
"*",
")",
"malloc",
"(",
"sizeof",
"(",
"String",
")",
")",
";",
"s",
"->",
"stuff",
"=",
"string",
";",
"s",
"->",
"self",
"=",
"s",
";",
"s",
"->",
"length",
"=",
"&",
"stringLength",
";",
"s",
"->",
"forEach",
"=",
"&",
"forEach",
";",
"s",
"->",
"searchFor",
"=",
"&",
"searchFor",
";",
"s",
"->",
"isBlank",
"=",
"&",
"isBlank",
";",
"s",
"->",
"isEqual",
"=",
"&",
"isEqual",
";",
"s",
"->",
"concat",
"=",
"&",
"concat",
";",
"s",
"->",
"setString",
"=",
"&",
"setString",
";",
"s",
"->",
"exportString",
"=",
"&",
"exportString",
";",
"return",
"s",
";",
"}"
] | Constructor. | [
"Constructor",
"."
] | [] | [
{
"param": "string",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "string",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
909c67f2cec8fb3568dd98e385b7a88b8ba3d600 | tornado12345/ChakraCore | lib/Runtime/Debug/TTSupport.h | [
"MIT"
] | C | AddNewBlock | void | void AddNewBlock()
{
byte* allocBlock = TT_HEAP_ALLOC_ARRAY(byte, this->m_slabBlockSize);
TTDAssert((reinterpret_cast<uint64>(allocBlock) & 0x3) == 0, "We have non-word aligned allocations so all our later work is not so useful");
SlabBlock* newBlock = (SlabBlock*)allocBlock;
byte* dataArray = (allocBlock + TTD_SLAB_BLOCK_SIZE);
this->m_currPos = dataArray;
this->m_endPos = dataArray + TTD_SLAB_BLOCK_USABLE_SIZE(this->m_slabBlockSize);
newBlock->BlockData = dataArray;
newBlock->Next = nullptr;
newBlock->Previous = this->m_headBlock;
newBlock->RefCounter = 0;
this->m_headBlock->Next = newBlock;
this->m_headBlock = newBlock;
} | //Get a new block in the slab | Get a new block in the slab | [
"Get",
"a",
"new",
"block",
"in",
"the",
"slab"
] | void AddNewBlock()
{
byte* allocBlock = TT_HEAP_ALLOC_ARRAY(byte, this->m_slabBlockSize);
TTDAssert((reinterpret_cast<uint64>(allocBlock) & 0x3) == 0, "We have non-word aligned allocations so all our later work is not so useful");
SlabBlock* newBlock = (SlabBlock*)allocBlock;
byte* dataArray = (allocBlock + TTD_SLAB_BLOCK_SIZE);
this->m_currPos = dataArray;
this->m_endPos = dataArray + TTD_SLAB_BLOCK_USABLE_SIZE(this->m_slabBlockSize);
newBlock->BlockData = dataArray;
newBlock->Next = nullptr;
newBlock->Previous = this->m_headBlock;
newBlock->RefCounter = 0;
this->m_headBlock->Next = newBlock;
this->m_headBlock = newBlock;
} | [
"void",
"AddNewBlock",
"(",
")",
"{",
"byte",
"*",
"allocBlock",
"=",
"TT_HEAP_ALLOC_ARRAY",
"(",
"byte",
",",
"this",
"->",
"m_slabBlockSize",
")",
";",
"TTDAssert",
"(",
"(",
"reinterpret_cast",
"<",
"uint64",
">",
"(",
"allocBlock",
")",
"&",
"0x3",
")",
"==",
"0",
",",
"\"",
"\"",
")",
";",
"SlabBlock",
"*",
"newBlock",
"=",
"(",
"SlabBlock",
"*",
")",
"allocBlock",
";",
"byte",
"*",
"dataArray",
"=",
"(",
"allocBlock",
"+",
"TTD_SLAB_BLOCK_SIZE",
")",
";",
"this",
"->",
"m_currPos",
"=",
"dataArray",
";",
"this",
"->",
"m_endPos",
"=",
"dataArray",
"+",
"TTD_SLAB_BLOCK_USABLE_SIZE",
"(",
"this",
"->",
"m_slabBlockSize",
")",
";",
"newBlock",
"->",
"BlockData",
"=",
"dataArray",
";",
"newBlock",
"->",
"Next",
"=",
"nullptr",
";",
"newBlock",
"->",
"Previous",
"=",
"this",
"->",
"m_headBlock",
";",
"newBlock",
"->",
"RefCounter",
"=",
"0",
";",
"this",
"->",
"m_headBlock",
"->",
"Next",
"=",
"newBlock",
";",
"this",
"->",
"m_headBlock",
"=",
"newBlock",
";",
"}"
] | Get a new block in the slab | [
"Get",
"a",
"new",
"block",
"in",
"the",
"slab"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
909c67f2cec8fb3568dd98e385b7a88b8ba3d600 | tornado12345/ChakraCore | lib/Runtime/Debug/TTSupport.h | [
"MIT"
] | C | CommitLargeBlockAllocation | void | void CommitLargeBlockAllocation(LargeSlabBlock* newBlock, size_t blockSize)
{
#if ENABLE_TTD_INTERNAL_DIAGNOSTICS
this->m_totalAllocatedSize += blockSize;
#endif
if (this->m_largeBlockList != nullptr)
{
this->m_largeBlockList->Next = newBlock;
}
this->m_largeBlockList = newBlock;
} | //Commit the allocation of a large block | Commit the allocation of a large block | [
"Commit",
"the",
"allocation",
"of",
"a",
"large",
"block"
] | void CommitLargeBlockAllocation(LargeSlabBlock* newBlock, size_t blockSize)
{
#if ENABLE_TTD_INTERNAL_DIAGNOSTICS
this->m_totalAllocatedSize += blockSize;
#endif
if (this->m_largeBlockList != nullptr)
{
this->m_largeBlockList->Next = newBlock;
}
this->m_largeBlockList = newBlock;
} | [
"void",
"CommitLargeBlockAllocation",
"(",
"LargeSlabBlock",
"*",
"newBlock",
",",
"size_t",
"blockSize",
")",
"{",
"#if",
"ENABLE_TTD_INTERNAL_DIAGNOSTICS",
"\n",
"this",
"->",
"m_totalAllocatedSize",
"+=",
"blockSize",
";",
"#endif",
"if",
"(",
"this",
"->",
"m_largeBlockList",
"!=",
"nullptr",
")",
"{",
"this",
"->",
"m_largeBlockList",
"->",
"Next",
"=",
"newBlock",
";",
"}",
"this",
"->",
"m_largeBlockList",
"=",
"newBlock",
";",
"}"
] | Commit the allocation of a large block | [
"Commit",
"the",
"allocation",
"of",
"a",
"large",
"block"
] | [] | [
{
"param": "newBlock",
"type": "LargeSlabBlock"
},
{
"param": "blockSize",
"type": "size_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "newBlock",
"type": "LargeSlabBlock",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "blockSize",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
909c67f2cec8fb3568dd98e385b7a88b8ba3d600 | tornado12345/ChakraCore | lib/Runtime/Debug/TTSupport.h | [
"MIT"
] | C | CopyRawNullTerminatedStringInto | char16 | const char16* CopyRawNullTerminatedStringInto(const char16* str)
{
if (str == nullptr)
{
return nullptr;
}
else
{
size_t length = wcslen(str) + 1;
size_t byteLength = length * sizeof(char16);
char16* res = this->SlabAllocateArray<char16>(length);
js_memcpy_s(res, byteLength, str, byteLength);
return res;
}
} | //clone a null terminated char16* string (or nullptr) into the allocator -- currently only used for wellknown tokens | clone a null terminated char16* string (or nullptr) into the allocator -- currently only used for wellknown tokens | [
"clone",
"a",
"null",
"terminated",
"char16",
"*",
"string",
"(",
"or",
"nullptr",
")",
"into",
"the",
"allocator",
"--",
"currently",
"only",
"used",
"for",
"wellknown",
"tokens"
] | const char16* CopyRawNullTerminatedStringInto(const char16* str)
{
if (str == nullptr)
{
return nullptr;
}
else
{
size_t length = wcslen(str) + 1;
size_t byteLength = length * sizeof(char16);
char16* res = this->SlabAllocateArray<char16>(length);
js_memcpy_s(res, byteLength, str, byteLength);
return res;
}
} | [
"const",
"char16",
"*",
"CopyRawNullTerminatedStringInto",
"(",
"const",
"char16",
"*",
"str",
")",
"{",
"if",
"(",
"str",
"==",
"nullptr",
")",
"{",
"return",
"nullptr",
";",
"}",
"else",
"{",
"size_t",
"length",
"=",
"wcslen",
"(",
"str",
")",
"+",
"1",
";",
"size_t",
"byteLength",
"=",
"length",
"*",
"sizeof",
"(",
"char16",
")",
";",
"char16",
"*",
"res",
"=",
"this",
"->",
"SlabAllocateArray",
"<",
"char16",
">",
"(",
"length",
")",
";",
"js_memcpy_s",
"(",
"res",
",",
"byteLength",
",",
"str",
",",
"byteLength",
")",
";",
"return",
"res",
";",
"}",
"}"
] | clone a null terminated char16* string (or nullptr) into the allocator -- currently only used for wellknown tokens | [
"clone",
"a",
"null",
"terminated",
"char16",
"*",
"string",
"(",
"or",
"nullptr",
")",
"into",
"the",
"allocator",
"--",
"currently",
"only",
"used",
"for",
"wellknown",
"tokens"
] | [] | [
{
"param": "str",
"type": "char16"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "str",
"type": "char16",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
909c67f2cec8fb3568dd98e385b7a88b8ba3d600 | tornado12345/ChakraCore | lib/Runtime/Debug/TTSupport.h | [
"MIT"
] | C | UnlinkAllocation | void | void UnlinkAllocation(const void* allocation)
{
TTDAssert(canUnlink != 0, "Unlink not allowed with this slab allocator.");
TTDAssert(this->m_reserveActiveBytes == 0, "We don't have anything reserved.");
//get the meta-data for this allocation and see if it is a
byte* realBase = ((byte*)allocation) - canUnlink;
ptrdiff_t offset = *((ptrdiff_t*)realBase);
if (offset == 0)
{
//it is a large allocation just free it
LargeSlabBlock* largeBlock = (LargeSlabBlock*)(((byte*)allocation) - TTD_LARGE_SLAB_BLOCK_SIZE);
if (largeBlock == this->m_largeBlockList)
{
TTDAssert(largeBlock->Next == nullptr, "Should always have a null next at head");
this->m_largeBlockList = this->m_largeBlockList->Previous;
if (this->m_largeBlockList != nullptr)
{
this->m_largeBlockList->Next = nullptr;
}
}
else
{
if (largeBlock->Next != nullptr)
{
largeBlock->Next->Previous = largeBlock->Previous;
}
if (largeBlock->Previous != nullptr)
{
largeBlock->Previous->Next = largeBlock->Next;
}
}
TT_HEAP_FREE_ARRAY(byte, (byte*)largeBlock, largeBlock->TotalBlockSize);
}
else
{
//lookup the slab block and do ref counting
SlabBlock* block = (SlabBlock*)(realBase - offset);
block->RefCounter--;
if (block->RefCounter == 0)
{
if (block == this->m_headBlock)
{
//we always need a head block to allocate out of -- so instead of deleting just reset it
this->m_currPos = this->m_headBlock->BlockData;
this->m_endPos = this->m_headBlock->BlockData + TTD_SLAB_BLOCK_USABLE_SIZE(this->m_slabBlockSize);
memset(this->m_currPos, 0, TTD_SLAB_BLOCK_USABLE_SIZE(this->m_slabBlockSize));
this->m_headBlock->RefCounter = 0;
}
else
{
if (block->Next != nullptr)
{
block->Next->Previous = block->Previous;
}
if (block->Previous != nullptr)
{
block->Previous->Next = block->Next;
}
TT_HEAP_FREE_ARRAY(byte, (byte*)block, this->m_slabBlockSize);
}
}
}
} | //If allowed unlink the memory allocation specified and free the block if it is no longer used by anyone | If allowed unlink the memory allocation specified and free the block if it is no longer used by anyone | [
"If",
"allowed",
"unlink",
"the",
"memory",
"allocation",
"specified",
"and",
"free",
"the",
"block",
"if",
"it",
"is",
"no",
"longer",
"used",
"by",
"anyone"
] | void UnlinkAllocation(const void* allocation)
{
TTDAssert(canUnlink != 0, "Unlink not allowed with this slab allocator.");
TTDAssert(this->m_reserveActiveBytes == 0, "We don't have anything reserved.");
byte* realBase = ((byte*)allocation) - canUnlink;
ptrdiff_t offset = *((ptrdiff_t*)realBase);
if (offset == 0)
{
LargeSlabBlock* largeBlock = (LargeSlabBlock*)(((byte*)allocation) - TTD_LARGE_SLAB_BLOCK_SIZE);
if (largeBlock == this->m_largeBlockList)
{
TTDAssert(largeBlock->Next == nullptr, "Should always have a null next at head");
this->m_largeBlockList = this->m_largeBlockList->Previous;
if (this->m_largeBlockList != nullptr)
{
this->m_largeBlockList->Next = nullptr;
}
}
else
{
if (largeBlock->Next != nullptr)
{
largeBlock->Next->Previous = largeBlock->Previous;
}
if (largeBlock->Previous != nullptr)
{
largeBlock->Previous->Next = largeBlock->Next;
}
}
TT_HEAP_FREE_ARRAY(byte, (byte*)largeBlock, largeBlock->TotalBlockSize);
}
else
{
SlabBlock* block = (SlabBlock*)(realBase - offset);
block->RefCounter--;
if (block->RefCounter == 0)
{
if (block == this->m_headBlock)
{
this->m_currPos = this->m_headBlock->BlockData;
this->m_endPos = this->m_headBlock->BlockData + TTD_SLAB_BLOCK_USABLE_SIZE(this->m_slabBlockSize);
memset(this->m_currPos, 0, TTD_SLAB_BLOCK_USABLE_SIZE(this->m_slabBlockSize));
this->m_headBlock->RefCounter = 0;
}
else
{
if (block->Next != nullptr)
{
block->Next->Previous = block->Previous;
}
if (block->Previous != nullptr)
{
block->Previous->Next = block->Next;
}
TT_HEAP_FREE_ARRAY(byte, (byte*)block, this->m_slabBlockSize);
}
}
}
} | [
"void",
"UnlinkAllocation",
"(",
"const",
"void",
"*",
"allocation",
")",
"{",
"TTDAssert",
"(",
"canUnlink",
"!=",
"0",
",",
"\"",
"\"",
")",
";",
"TTDAssert",
"(",
"this",
"->",
"m_reserveActiveBytes",
"==",
"0",
",",
"\"",
"\"",
")",
";",
"byte",
"*",
"realBase",
"=",
"(",
"(",
"byte",
"*",
")",
"allocation",
")",
"-",
"canUnlink",
";",
"ptrdiff_t",
"offset",
"=",
"*",
"(",
"(",
"ptrdiff_t",
"*",
")",
"realBase",
")",
";",
"if",
"(",
"offset",
"==",
"0",
")",
"{",
"LargeSlabBlock",
"*",
"largeBlock",
"=",
"(",
"LargeSlabBlock",
"*",
")",
"(",
"(",
"(",
"byte",
"*",
")",
"allocation",
")",
"-",
"TTD_LARGE_SLAB_BLOCK_SIZE",
")",
";",
"if",
"(",
"largeBlock",
"==",
"this",
"->",
"m_largeBlockList",
")",
"{",
"TTDAssert",
"(",
"largeBlock",
"->",
"Next",
"==",
"nullptr",
",",
"\"",
"\"",
")",
";",
"this",
"->",
"m_largeBlockList",
"=",
"this",
"->",
"m_largeBlockList",
"->",
"Previous",
";",
"if",
"(",
"this",
"->",
"m_largeBlockList",
"!=",
"nullptr",
")",
"{",
"this",
"->",
"m_largeBlockList",
"->",
"Next",
"=",
"nullptr",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"largeBlock",
"->",
"Next",
"!=",
"nullptr",
")",
"{",
"largeBlock",
"->",
"Next",
"->",
"Previous",
"=",
"largeBlock",
"->",
"Previous",
";",
"}",
"if",
"(",
"largeBlock",
"->",
"Previous",
"!=",
"nullptr",
")",
"{",
"largeBlock",
"->",
"Previous",
"->",
"Next",
"=",
"largeBlock",
"->",
"Next",
";",
"}",
"}",
"TT_HEAP_FREE_ARRAY",
"(",
"byte",
",",
"(",
"byte",
"*",
")",
"largeBlock",
",",
"largeBlock",
"->",
"TotalBlockSize",
")",
";",
"}",
"else",
"{",
"SlabBlock",
"*",
"block",
"=",
"(",
"SlabBlock",
"*",
")",
"(",
"realBase",
"-",
"offset",
")",
";",
"block",
"->",
"RefCounter",
"--",
";",
"if",
"(",
"block",
"->",
"RefCounter",
"==",
"0",
")",
"{",
"if",
"(",
"block",
"==",
"this",
"->",
"m_headBlock",
")",
"{",
"this",
"->",
"m_currPos",
"=",
"this",
"->",
"m_headBlock",
"->",
"BlockData",
";",
"this",
"->",
"m_endPos",
"=",
"this",
"->",
"m_headBlock",
"->",
"BlockData",
"+",
"TTD_SLAB_BLOCK_USABLE_SIZE",
"(",
"this",
"->",
"m_slabBlockSize",
")",
";",
"memset",
"(",
"this",
"->",
"m_currPos",
",",
"0",
",",
"TTD_SLAB_BLOCK_USABLE_SIZE",
"(",
"this",
"->",
"m_slabBlockSize",
")",
")",
";",
"this",
"->",
"m_headBlock",
"->",
"RefCounter",
"=",
"0",
";",
"}",
"else",
"{",
"if",
"(",
"block",
"->",
"Next",
"!=",
"nullptr",
")",
"{",
"block",
"->",
"Next",
"->",
"Previous",
"=",
"block",
"->",
"Previous",
";",
"}",
"if",
"(",
"block",
"->",
"Previous",
"!=",
"nullptr",
")",
"{",
"block",
"->",
"Previous",
"->",
"Next",
"=",
"block",
"->",
"Next",
";",
"}",
"TT_HEAP_FREE_ARRAY",
"(",
"byte",
",",
"(",
"byte",
"*",
")",
"block",
",",
"this",
"->",
"m_slabBlockSize",
")",
";",
"}",
"}",
"}",
"}"
] | If allowed unlink the memory allocation specified and free the block if it is no longer used by anyone | [
"If",
"allowed",
"unlink",
"the",
"memory",
"allocation",
"specified",
"and",
"free",
"the",
"block",
"if",
"it",
"is",
"no",
"longer",
"used",
"by",
"anyone"
] | [
"//get the meta-data for this allocation and see if it is a",
"//it is a large allocation just free it",
"//lookup the slab block and do ref counting",
"//we always need a head block to allocate out of -- so instead of deleting just reset it"
] | [
{
"param": "allocation",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "allocation",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
909c67f2cec8fb3568dd98e385b7a88b8ba3d600 | tornado12345/ChakraCore | lib/Runtime/Debug/TTSupport.h | [
"MIT"
] | C | AddEntry | void | void AddEntry(T data)
{
TTDAssert(this->m_inlineHeadBlock.CurrPos <= this->m_inlineHeadBlock.EndPos, "We are off the end of the array");
TTDAssert((((byte*)this->m_inlineHeadBlock.CurrPos) - ((byte*)this->m_inlineHeadBlock.BlockData)) / sizeof(T) <= allocSize, "We are off the end of the array");
if (this->m_inlineHeadBlock.CurrPos == this->m_inlineHeadBlock.EndPos)
{
this->AddArrayLink();
}
*(this->m_inlineHeadBlock.CurrPos) = data;
this->m_inlineHeadBlock.CurrPos++;
} | //Add the entry to the unordered list | Add the entry to the unordered list | [
"Add",
"the",
"entry",
"to",
"the",
"unordered",
"list"
] | void AddEntry(T data)
{
TTDAssert(this->m_inlineHeadBlock.CurrPos <= this->m_inlineHeadBlock.EndPos, "We are off the end of the array");
TTDAssert((((byte*)this->m_inlineHeadBlock.CurrPos) - ((byte*)this->m_inlineHeadBlock.BlockData)) / sizeof(T) <= allocSize, "We are off the end of the array");
if (this->m_inlineHeadBlock.CurrPos == this->m_inlineHeadBlock.EndPos)
{
this->AddArrayLink();
}
*(this->m_inlineHeadBlock.CurrPos) = data;
this->m_inlineHeadBlock.CurrPos++;
} | [
"void",
"AddEntry",
"(",
"T",
"data",
")",
"{",
"TTDAssert",
"(",
"this",
"->",
"m_inlineHeadBlock",
".",
"CurrPos",
"<=",
"this",
"->",
"m_inlineHeadBlock",
".",
"EndPos",
",",
"\"",
"\"",
")",
";",
"TTDAssert",
"(",
"(",
"(",
"(",
"byte",
"*",
")",
"this",
"->",
"m_inlineHeadBlock",
".",
"CurrPos",
")",
"-",
"(",
"(",
"byte",
"*",
")",
"this",
"->",
"m_inlineHeadBlock",
".",
"BlockData",
")",
")",
"/",
"sizeof",
"(",
"T",
")",
"<=",
"allocSize",
",",
"\"",
"\"",
")",
";",
"if",
"(",
"this",
"->",
"m_inlineHeadBlock",
".",
"CurrPos",
"==",
"this",
"->",
"m_inlineHeadBlock",
".",
"EndPos",
")",
"{",
"this",
"->",
"AddArrayLink",
"(",
")",
";",
"}",
"*",
"(",
"this",
"->",
"m_inlineHeadBlock",
".",
"CurrPos",
")",
"=",
"data",
";",
"this",
"->",
"m_inlineHeadBlock",
".",
"CurrPos",
"++",
";",
"}"
] | Add the entry to the unordered list | [
"Add",
"the",
"entry",
"to",
"the",
"unordered",
"list"
] | [] | [
{
"param": "data",
"type": "T"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": "T",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
909c67f2cec8fb3568dd98e385b7a88b8ba3d600 | tornado12345/ChakraCore | lib/Runtime/Debug/TTSupport.h | [
"MIT"
] | C | NextOpenEntry | T | T* NextOpenEntry()
{
TTDAssert(this->m_inlineHeadBlock.CurrPos <= this->m_inlineHeadBlock.EndPos, "We are off the end of the array");
TTDAssert((((byte*)this->m_inlineHeadBlock.CurrPos) - ((byte*)this->m_inlineHeadBlock.BlockData)) / sizeof(T) <= allocSize, "We are off the end of the array");
if (this->m_inlineHeadBlock.CurrPos == this->m_inlineHeadBlock.EndPos)
{
this->AddArrayLink();
}
T* entry = this->m_inlineHeadBlock.CurrPos;
this->m_inlineHeadBlock.CurrPos++;
return entry;
} | //Get the next uninitialized entry (at the front of the sequence)
//We expect the caller to initialize this memory appropriately | Get the next uninitialized entry (at the front of the sequence)
We expect the caller to initialize this memory appropriately | [
"Get",
"the",
"next",
"uninitialized",
"entry",
"(",
"at",
"the",
"front",
"of",
"the",
"sequence",
")",
"We",
"expect",
"the",
"caller",
"to",
"initialize",
"this",
"memory",
"appropriately"
] | T* NextOpenEntry()
{
TTDAssert(this->m_inlineHeadBlock.CurrPos <= this->m_inlineHeadBlock.EndPos, "We are off the end of the array");
TTDAssert((((byte*)this->m_inlineHeadBlock.CurrPos) - ((byte*)this->m_inlineHeadBlock.BlockData)) / sizeof(T) <= allocSize, "We are off the end of the array");
if (this->m_inlineHeadBlock.CurrPos == this->m_inlineHeadBlock.EndPos)
{
this->AddArrayLink();
}
T* entry = this->m_inlineHeadBlock.CurrPos;
this->m_inlineHeadBlock.CurrPos++;
return entry;
} | [
"T",
"*",
"NextOpenEntry",
"(",
")",
"{",
"TTDAssert",
"(",
"this",
"->",
"m_inlineHeadBlock",
".",
"CurrPos",
"<=",
"this",
"->",
"m_inlineHeadBlock",
".",
"EndPos",
",",
"\"",
"\"",
")",
";",
"TTDAssert",
"(",
"(",
"(",
"(",
"byte",
"*",
")",
"this",
"->",
"m_inlineHeadBlock",
".",
"CurrPos",
")",
"-",
"(",
"(",
"byte",
"*",
")",
"this",
"->",
"m_inlineHeadBlock",
".",
"BlockData",
")",
")",
"/",
"sizeof",
"(",
"T",
")",
"<=",
"allocSize",
",",
"\"",
"\"",
")",
";",
"if",
"(",
"this",
"->",
"m_inlineHeadBlock",
".",
"CurrPos",
"==",
"this",
"->",
"m_inlineHeadBlock",
".",
"EndPos",
")",
"{",
"this",
"->",
"AddArrayLink",
"(",
")",
";",
"}",
"T",
"*",
"entry",
"=",
"this",
"->",
"m_inlineHeadBlock",
".",
"CurrPos",
";",
"this",
"->",
"m_inlineHeadBlock",
".",
"CurrPos",
"++",
";",
"return",
"entry",
";",
"}"
] | Get the next uninitialized entry (at the front of the sequence)
We expect the caller to initialize this memory appropriately | [
"Get",
"the",
"next",
"uninitialized",
"entry",
"(",
"at",
"the",
"front",
"of",
"the",
"sequence",
")",
"We",
"expect",
"the",
"caller",
"to",
"initialize",
"this",
"memory",
"appropriately"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
6a083aab2073e9cdabbb41464ffd92e6caa15f49 | paulbartell/tfm-staging | platform/ext/target/arm/diphda/tfm_hal_isolation.c | [
"BSD-3-Clause"
] | C | tfm_hal_bind_boundaries | nan | enum tfm_hal_status_t tfm_hal_bind_boundaries(
const struct partition_load_info_t *p_ldinf,
void **pp_boundaries)
{
(void)p_ldinf;
(void)pp_boundaries;
return TFM_HAL_SUCCESS;
} | /*
* Implementation of tfm_hal_bind_boundaries() on Diphda:
*
* The API encodes some attributes into a handle and returns it to SPM.
* The attributes include isolation boundaries, privilege, and MMIO information.
* When scheduler switches running partitions, SPM compares the handle between
* partitions to know if boundary update is necessary. If update is required,
* SPM passes the handle to platform to do platform settings and update
* isolation boundaries.
*/ | Implementation of tfm_hal_bind_boundaries() on Diphda:
The API encodes some attributes into a handle and returns it to SPM.
The attributes include isolation boundaries, privilege, and MMIO information.
When scheduler switches running partitions, SPM compares the handle between
partitions to know if boundary update is necessary. If update is required,
SPM passes the handle to platform to do platform settings and update
isolation boundaries. | [
"Implementation",
"of",
"tfm_hal_bind_boundaries",
"()",
"on",
"Diphda",
":",
"The",
"API",
"encodes",
"some",
"attributes",
"into",
"a",
"handle",
"and",
"returns",
"it",
"to",
"SPM",
".",
"The",
"attributes",
"include",
"isolation",
"boundaries",
"privilege",
"and",
"MMIO",
"information",
".",
"When",
"scheduler",
"switches",
"running",
"partitions",
"SPM",
"compares",
"the",
"handle",
"between",
"partitions",
"to",
"know",
"if",
"boundary",
"update",
"is",
"necessary",
".",
"If",
"update",
"is",
"required",
"SPM",
"passes",
"the",
"handle",
"to",
"platform",
"to",
"do",
"platform",
"settings",
"and",
"update",
"isolation",
"boundaries",
"."
] | enum tfm_hal_status_t tfm_hal_bind_boundaries(
const struct partition_load_info_t *p_ldinf,
void **pp_boundaries)
{
(void)p_ldinf;
(void)pp_boundaries;
return TFM_HAL_SUCCESS;
} | [
"enum",
"tfm_hal_status_t",
"tfm_hal_bind_boundaries",
"(",
"const",
"struct",
"partition_load_info_t",
"*",
"p_ldinf",
",",
"void",
"*",
"*",
"pp_boundaries",
")",
"{",
"(",
"void",
")",
"p_ldinf",
";",
"(",
"void",
")",
"pp_boundaries",
";",
"return",
"TFM_HAL_SUCCESS",
";",
"}"
] | Implementation of tfm_hal_bind_boundaries() on Diphda:
The API encodes some attributes into a handle and returns it to SPM. | [
"Implementation",
"of",
"tfm_hal_bind_boundaries",
"()",
"on",
"Diphda",
":",
"The",
"API",
"encodes",
"some",
"attributes",
"into",
"a",
"handle",
"and",
"returns",
"it",
"to",
"SPM",
"."
] | [] | [
{
"param": "p_ldinf",
"type": "struct partition_load_info_t"
},
{
"param": "pp_boundaries",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "p_ldinf",
"type": "struct partition_load_info_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pp_boundaries",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5cdcc718c7582cc5ebc7b5085f0998310c89645a | paulbartell/tfm-staging | secure_fw/partitions/protected_storage/ps_object_system.c | [
"BSD-3-Clause"
] | C | ps_remove_old_data | psa_status_t | static psa_status_t ps_remove_old_data(uint32_t old_fid)
{
psa_status_t err;
/* Delete old object table from the persistent area */
err = ps_object_table_delete_old_table();
if (err != PSA_SUCCESS) {
return err;
}
/* Delete old file from the persistent area */
return psa_its_remove(old_fid);
} | /**
* \brief Removes the old object table and object from the file system.
*
* \param[in] old_fid Old file ID to remove.
*
* \return Returns error code as specified in \ref psa_status_t
*/ | \brief Removes the old object table and object from the file system.
\param[in] old_fid Old file ID to remove.
\return Returns error code as specified in \ref psa_status_t | [
"\\",
"brief",
"Removes",
"the",
"old",
"object",
"table",
"and",
"object",
"from",
"the",
"file",
"system",
".",
"\\",
"param",
"[",
"in",
"]",
"old_fid",
"Old",
"file",
"ID",
"to",
"remove",
".",
"\\",
"return",
"Returns",
"error",
"code",
"as",
"specified",
"in",
"\\",
"ref",
"psa_status_t"
] | static psa_status_t ps_remove_old_data(uint32_t old_fid)
{
psa_status_t err;
err = ps_object_table_delete_old_table();
if (err != PSA_SUCCESS) {
return err;
}
return psa_its_remove(old_fid);
} | [
"static",
"psa_status_t",
"ps_remove_old_data",
"(",
"uint32_t",
"old_fid",
")",
"{",
"psa_status_t",
"err",
";",
"err",
"=",
"ps_object_table_delete_old_table",
"(",
")",
";",
"if",
"(",
"err",
"!=",
"PSA_SUCCESS",
")",
"{",
"return",
"err",
";",
"}",
"return",
"psa_its_remove",
"(",
"old_fid",
")",
";",
"}"
] | \brief Removes the old object table and object from the file system. | [
"\\",
"brief",
"Removes",
"the",
"old",
"object",
"table",
"and",
"object",
"from",
"the",
"file",
"system",
"."
] | [
"/* Delete old object table from the persistent area */",
"/* Delete old file from the persistent area */"
] | [
{
"param": "old_fid",
"type": "uint32_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "old_fid",
"type": "uint32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5cdcc718c7582cc5ebc7b5085f0998310c89645a | paulbartell/tfm-staging | secure_fw/partitions/protected_storage/ps_object_system.c | [
"BSD-3-Clause"
] | C | ps_write_object | psa_status_t | static psa_status_t ps_write_object(uint32_t wrt_size)
{
/* Add object identification and increase object version */
g_ps_object.header.fid = g_obj_tbl_info.fid;
g_ps_object.header.version++;
/* Save object version to be stored in the object table */
g_obj_tbl_info.version = g_ps_object.header.version;
return psa_its_set(g_obj_tbl_info.fid, wrt_size,
(const void *)&g_ps_object,
PSA_STORAGE_FLAG_NONE);
} | /**
* \brief Writes an object based on its object table info stored in
* g_obj_tbl_info and the input parameter.
*
* \param[in] wrt_size Number of bytes to write
*
* \return Returns error code as specified in \ref psa_status_t
*/ | \brief Writes an object based on its object table info stored in
g_obj_tbl_info and the input parameter.
\param[in] wrt_size Number of bytes to write
\return Returns error code as specified in \ref psa_status_t | [
"\\",
"brief",
"Writes",
"an",
"object",
"based",
"on",
"its",
"object",
"table",
"info",
"stored",
"in",
"g_obj_tbl_info",
"and",
"the",
"input",
"parameter",
".",
"\\",
"param",
"[",
"in",
"]",
"wrt_size",
"Number",
"of",
"bytes",
"to",
"write",
"\\",
"return",
"Returns",
"error",
"code",
"as",
"specified",
"in",
"\\",
"ref",
"psa_status_t"
] | static psa_status_t ps_write_object(uint32_t wrt_size)
{
g_ps_object.header.fid = g_obj_tbl_info.fid;
g_ps_object.header.version++;
g_obj_tbl_info.version = g_ps_object.header.version;
return psa_its_set(g_obj_tbl_info.fid, wrt_size,
(const void *)&g_ps_object,
PSA_STORAGE_FLAG_NONE);
} | [
"static",
"psa_status_t",
"ps_write_object",
"(",
"uint32_t",
"wrt_size",
")",
"{",
"g_ps_object",
".",
"header",
".",
"fid",
"=",
"g_obj_tbl_info",
".",
"fid",
";",
"g_ps_object",
".",
"header",
".",
"version",
"++",
";",
"g_obj_tbl_info",
".",
"version",
"=",
"g_ps_object",
".",
"header",
".",
"version",
";",
"return",
"psa_its_set",
"(",
"g_obj_tbl_info",
".",
"fid",
",",
"wrt_size",
",",
"(",
"const",
"void",
"*",
")",
"&",
"g_ps_object",
",",
"PSA_STORAGE_FLAG_NONE",
")",
";",
"}"
] | \brief Writes an object based on its object table info stored in
g_obj_tbl_info and the input parameter. | [
"\\",
"brief",
"Writes",
"an",
"object",
"based",
"on",
"its",
"object",
"table",
"info",
"stored",
"in",
"g_obj_tbl_info",
"and",
"the",
"input",
"parameter",
"."
] | [
"/* Add object identification and increase object version */",
"/* Save object version to be stored in the object table */"
] | [
{
"param": "wrt_size",
"type": "uint32_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "wrt_size",
"type": "uint32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
823e293f906c1e3a70cd08b6264d3db6086eee78 | paulbartell/tfm-staging | secure_fw/spm/cmsis_psa/arch/tfm_arch.c | [
"BSD-3-Clause"
] | C | tfm_arch_init_state_context | void | static void tfm_arch_init_state_context(struct tfm_state_context_t *p_sctx,
void *param,
uintptr_t pfn, uintptr_t pfnlr)
{
p_sctx->r0 = (uint32_t)param;
p_sctx->ra = (uint32_t)pfn;
p_sctx->lr = (uint32_t)pfnlr;
p_sctx->xpsr = XPSR_T32;
} | /*
* Initializes the State Context. The Context is used to do Except Return to
* Thread Mode to start a function.
*
* p_sctx[out] - pointer to the State Context to be initialized.
* param [in] - The parameter for the function to start
* pfn [in] - Pointer to the function to excute
* pfnlr [in] - The Link Register of the State Context - the return address of
* the function
*/ | Initializes the State Context. The Context is used to do Except Return to
Thread Mode to start a function.
p_sctx[out] - pointer to the State Context to be initialized.
param [in] - The parameter for the function to start
pfn [in] - Pointer to the function to excute
pfnlr [in] - The Link Register of the State Context - the return address of
the function | [
"Initializes",
"the",
"State",
"Context",
".",
"The",
"Context",
"is",
"used",
"to",
"do",
"Except",
"Return",
"to",
"Thread",
"Mode",
"to",
"start",
"a",
"function",
".",
"p_sctx",
"[",
"out",
"]",
"-",
"pointer",
"to",
"the",
"State",
"Context",
"to",
"be",
"initialized",
".",
"param",
"[",
"in",
"]",
"-",
"The",
"parameter",
"for",
"the",
"function",
"to",
"start",
"pfn",
"[",
"in",
"]",
"-",
"Pointer",
"to",
"the",
"function",
"to",
"excute",
"pfnlr",
"[",
"in",
"]",
"-",
"The",
"Link",
"Register",
"of",
"the",
"State",
"Context",
"-",
"the",
"return",
"address",
"of",
"the",
"function"
] | static void tfm_arch_init_state_context(struct tfm_state_context_t *p_sctx,
void *param,
uintptr_t pfn, uintptr_t pfnlr)
{
p_sctx->r0 = (uint32_t)param;
p_sctx->ra = (uint32_t)pfn;
p_sctx->lr = (uint32_t)pfnlr;
p_sctx->xpsr = XPSR_T32;
} | [
"static",
"void",
"tfm_arch_init_state_context",
"(",
"struct",
"tfm_state_context_t",
"*",
"p_sctx",
",",
"void",
"*",
"param",
",",
"uintptr_t",
"pfn",
",",
"uintptr_t",
"pfnlr",
")",
"{",
"p_sctx",
"->",
"r0",
"=",
"(",
"uint32_t",
")",
"param",
";",
"p_sctx",
"->",
"ra",
"=",
"(",
"uint32_t",
")",
"pfn",
";",
"p_sctx",
"->",
"lr",
"=",
"(",
"uint32_t",
")",
"pfnlr",
";",
"p_sctx",
"->",
"xpsr",
"=",
"XPSR_T32",
";",
"}"
] | Initializes the State Context. | [
"Initializes",
"the",
"State",
"Context",
"."
] | [] | [
{
"param": "p_sctx",
"type": "struct tfm_state_context_t"
},
{
"param": "param",
"type": "void"
},
{
"param": "pfn",
"type": "uintptr_t"
},
{
"param": "pfnlr",
"type": "uintptr_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "p_sctx",
"type": "struct tfm_state_context_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "param",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pfn",
"type": "uintptr_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pfnlr",
"type": "uintptr_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a7259d82945aa1117c7c5437dddd288cf11aaadc | watchpoints/daily-interview | code/2021/lex-yacc-examples/temp/y.tab.c | [
"Apache-2.0"
] | C | yydestruct | void | static void
yydestruct (const char *yymsg,
yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
{
YYUSE (yyvaluep);
if (!yymsg)
yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
YYUSE (yykind);
YY_IGNORE_MAYBE_UNINITIALIZED_END
} | /*-----------------------------------------------.
| Release the memory associated to this symbol. |
`-----------------------------------------------*/ | .
| Release the memory associated to this symbol. | [
".",
"|",
"Release",
"the",
"memory",
"associated",
"to",
"this",
"symbol",
"."
] | static void
yydestruct (const char *yymsg,
yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
{
YYUSE (yyvaluep);
if (!yymsg)
yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
YYUSE (yykind);
YY_IGNORE_MAYBE_UNINITIALIZED_END
} | [
"static",
"void",
"yydestruct",
"(",
"const",
"char",
"*",
"yymsg",
",",
"yysymbol_kind_t",
"yykind",
",",
"YYSTYPE",
"*",
"yyvaluep",
")",
"{",
"YYUSE",
"(",
"yyvaluep",
")",
";",
"if",
"(",
"!",
"yymsg",
")",
"yymsg",
"=",
"\"",
"\"",
";",
"YY_SYMBOL_PRINT",
"(",
"yymsg",
",",
"yykind",
",",
"yyvaluep",
",",
"yylocationp",
")",
";",
"YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN",
"YYUSE",
"(",
"yykind",
")",
";",
"YY_IGNORE_MAYBE_UNINITIALIZED_END",
"",
"}"
] | . | [
"."
] | [] | [
{
"param": "yymsg",
"type": "char"
},
{
"param": "yykind",
"type": "yysymbol_kind_t"
},
{
"param": "yyvaluep",
"type": "YYSTYPE"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "yymsg",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "yykind",
"type": "yysymbol_kind_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "yyvaluep",
"type": "YYSTYPE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
04f43de7c93811fa7e19dd1de85caafc21028a3b | valerie-sd/mumt306project | src/midicsv-1.1/midicsv.c | [
"MIT"
] | C | vlength | vlint | static vlint vlength(byte **trk, long *trklen)
{
vlint value;
byte ch;
byte *cp = *trk;
trklen--;
if ((value = *cp++) & 0x80) {
value &= 0x7F;
do {
value = (value << 7) | ((ch = *cp++) & 0x7F);
trklen--;
} while (ch & 0x80);
}
#ifdef DUMP
fprintf(stderr, "Time lapse: %d bytes, %d\n", cp - *trk, value);
#endif
*trk = cp;
return value;
} | /* VLENGTH -- Parse variable length item from in-memory track */ | VLENGTH -- Parse variable length item from in-memory track | [
"VLENGTH",
"--",
"Parse",
"variable",
"length",
"item",
"from",
"in",
"-",
"memory",
"track"
] | static vlint vlength(byte **trk, long *trklen)
{
vlint value;
byte ch;
byte *cp = *trk;
trklen--;
if ((value = *cp++) & 0x80) {
value &= 0x7F;
do {
value = (value << 7) | ((ch = *cp++) & 0x7F);
trklen--;
} while (ch & 0x80);
}
#ifdef DUMP
fprintf(stderr, "Time lapse: %d bytes, %d\n", cp - *trk, value);
#endif
*trk = cp;
return value;
} | [
"static",
"vlint",
"vlength",
"(",
"byte",
"*",
"*",
"trk",
",",
"long",
"*",
"trklen",
")",
"{",
"vlint",
"value",
";",
"byte",
"ch",
";",
"byte",
"*",
"cp",
"=",
"*",
"trk",
";",
"trklen",
"--",
";",
"if",
"(",
"(",
"value",
"=",
"*",
"cp",
"++",
")",
"&",
"0x80",
")",
"{",
"value",
"&=",
"0x7F",
";",
"do",
"{",
"value",
"=",
"(",
"value",
"<<",
"7",
")",
"|",
"(",
"(",
"ch",
"=",
"*",
"cp",
"++",
")",
"&",
"0x7F",
")",
";",
"trklen",
"--",
";",
"}",
"while",
"(",
"ch",
"&",
"0x80",
")",
";",
"}",
"#ifdef",
"DUMP",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"cp",
"-",
"*",
"trk",
",",
"value",
")",
";",
"#endif",
"*",
"trk",
"=",
"cp",
";",
"return",
"value",
";",
"}"
] | VLENGTH -- Parse variable length item from in-memory track | [
"VLENGTH",
"--",
"Parse",
"variable",
"length",
"item",
"from",
"in",
"-",
"memory",
"track"
] | [] | [
{
"param": "trk",
"type": "byte"
},
{
"param": "trklen",
"type": "long"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "trk",
"type": "byte",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "trklen",
"type": "long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b6d4d1aa659d1d282ea83d0254012efb0dadf7ca | elmot/open-oscilloscope-stm32f3 | Src/usbd_conf.c | [
"MIT"
] | C | HAL_PCD_SuspendCallback | void | void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
{
/* Inform USB library that core enters in suspend Mode */
USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData);
/*Enter in STOP mode */
/* USER CODE BEGIN 2 */
if (hpcd->Init.low_power_enable)
{
/* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register */
SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
}
/* USER CODE END 2 */
} | /**
* @brief Suspend callback.
* When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it)
* @param hpcd: PCD handle
* @retval None
*/ | @brief Suspend callback.
When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it)
@param hpcd: PCD handle
@retval None | [
"@brief",
"Suspend",
"callback",
".",
"When",
"Low",
"power",
"mode",
"is",
"enabled",
"the",
"debug",
"cannot",
"be",
"used",
"(",
"IAR",
"Keil",
"doesn",
"'",
"t",
"support",
"it",
")",
"@param",
"hpcd",
":",
"PCD",
"handle",
"@retval",
"None"
] | void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
{
USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData);
if (hpcd->Init.low_power_enable)
{
SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
}
} | [
"void",
"HAL_PCD_SuspendCallback",
"(",
"PCD_HandleTypeDef",
"*",
"hpcd",
")",
"{",
"USBD_LL_Suspend",
"(",
"(",
"USBD_HandleTypeDef",
"*",
")",
"hpcd",
"->",
"pData",
")",
";",
"if",
"(",
"hpcd",
"->",
"Init",
".",
"low_power_enable",
")",
"{",
"SCB",
"->",
"SCR",
"|=",
"(",
"uint32_t",
")",
"(",
"(",
"uint32_t",
")",
"(",
"SCB_SCR_SLEEPDEEP_Msk",
"|",
"SCB_SCR_SLEEPONEXIT_Msk",
")",
")",
";",
"}",
"}"
] | @brief Suspend callback. | [
"@brief",
"Suspend",
"callback",
"."
] | [
"/* Inform USB library that core enters in suspend Mode */",
"/*Enter in STOP mode */",
"/* USER CODE BEGIN 2 */",
"/* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register */",
"/* USER CODE END 2 */"
] | [
{
"param": "hpcd",
"type": "PCD_HandleTypeDef"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hpcd",
"type": "PCD_HandleTypeDef",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b6d4d1aa659d1d282ea83d0254012efb0dadf7ca | elmot/open-oscilloscope-stm32f3 | Src/usbd_conf.c | [
"MIT"
] | C | USBD_LL_Init | USBD_StatusTypeDef | USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev)
{
/* Init USB_IP */
/* Link The driver to the stack */
hpcd_USB_FS.pData = pdev;
pdev->pData = &hpcd_USB_FS;
hpcd_USB_FS.Instance = USB;
hpcd_USB_FS.Init.dev_endpoints = 8;
hpcd_USB_FS.Init.speed = PCD_SPEED_FULL;
hpcd_USB_FS.Init.ep0_mps = DEP0CTL_MPS_64;
hpcd_USB_FS.Init.phy_itface = PCD_PHY_EMBEDDED;
hpcd_USB_FS.Init.low_power_enable = DISABLE;
hpcd_USB_FS.Init.battery_charging_enable = DISABLE;
if (HAL_PCD_Init(&hpcd_USB_FS) != HAL_OK)
{
Error_Handler();
}
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x00 , PCD_SNG_BUF, 0x18);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x80 , PCD_SNG_BUF, 0x58);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x81 , PCD_SNG_BUF, 0xC0);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x01 , PCD_SNG_BUF, 0x110);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x82 , PCD_SNG_BUF, 0x100);
return USBD_OK;
} | /**
* @brief Initializes the Low Level portion of the Device driver.
* @param pdev: Device handle
* @retval USBD Status
*/ | @brief Initializes the Low Level portion of the Device driver.
@param pdev: Device handle
@retval USBD Status | [
"@brief",
"Initializes",
"the",
"Low",
"Level",
"portion",
"of",
"the",
"Device",
"driver",
".",
"@param",
"pdev",
":",
"Device",
"handle",
"@retval",
"USBD",
"Status"
] | USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev)
{
hpcd_USB_FS.pData = pdev;
pdev->pData = &hpcd_USB_FS;
hpcd_USB_FS.Instance = USB;
hpcd_USB_FS.Init.dev_endpoints = 8;
hpcd_USB_FS.Init.speed = PCD_SPEED_FULL;
hpcd_USB_FS.Init.ep0_mps = DEP0CTL_MPS_64;
hpcd_USB_FS.Init.phy_itface = PCD_PHY_EMBEDDED;
hpcd_USB_FS.Init.low_power_enable = DISABLE;
hpcd_USB_FS.Init.battery_charging_enable = DISABLE;
if (HAL_PCD_Init(&hpcd_USB_FS) != HAL_OK)
{
Error_Handler();
}
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x00 , PCD_SNG_BUF, 0x18);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x80 , PCD_SNG_BUF, 0x58);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x81 , PCD_SNG_BUF, 0xC0);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x01 , PCD_SNG_BUF, 0x110);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x82 , PCD_SNG_BUF, 0x100);
return USBD_OK;
} | [
"USBD_StatusTypeDef",
"USBD_LL_Init",
"(",
"USBD_HandleTypeDef",
"*",
"pdev",
")",
"{",
"hpcd_USB_FS",
".",
"pData",
"=",
"pdev",
";",
"pdev",
"->",
"pData",
"=",
"&",
"hpcd_USB_FS",
";",
"hpcd_USB_FS",
".",
"Instance",
"=",
"USB",
";",
"hpcd_USB_FS",
".",
"Init",
".",
"dev_endpoints",
"=",
"8",
";",
"hpcd_USB_FS",
".",
"Init",
".",
"speed",
"=",
"PCD_SPEED_FULL",
";",
"hpcd_USB_FS",
".",
"Init",
".",
"ep0_mps",
"=",
"DEP0CTL_MPS_64",
";",
"hpcd_USB_FS",
".",
"Init",
".",
"phy_itface",
"=",
"PCD_PHY_EMBEDDED",
";",
"hpcd_USB_FS",
".",
"Init",
".",
"low_power_enable",
"=",
"DISABLE",
";",
"hpcd_USB_FS",
".",
"Init",
".",
"battery_charging_enable",
"=",
"DISABLE",
";",
"if",
"(",
"HAL_PCD_Init",
"(",
"&",
"hpcd_USB_FS",
")",
"!=",
"HAL_OK",
")",
"{",
"Error_Handler",
"(",
")",
";",
"}",
"HAL_PCDEx_PMAConfig",
"(",
"(",
"PCD_HandleTypeDef",
"*",
")",
"pdev",
"->",
"pData",
",",
"0x00",
",",
"PCD_SNG_BUF",
",",
"0x18",
")",
";",
"HAL_PCDEx_PMAConfig",
"(",
"(",
"PCD_HandleTypeDef",
"*",
")",
"pdev",
"->",
"pData",
",",
"0x80",
",",
"PCD_SNG_BUF",
",",
"0x58",
")",
";",
"HAL_PCDEx_PMAConfig",
"(",
"(",
"PCD_HandleTypeDef",
"*",
")",
"pdev",
"->",
"pData",
",",
"0x81",
",",
"PCD_SNG_BUF",
",",
"0xC0",
")",
";",
"HAL_PCDEx_PMAConfig",
"(",
"(",
"PCD_HandleTypeDef",
"*",
")",
"pdev",
"->",
"pData",
",",
"0x01",
",",
"PCD_SNG_BUF",
",",
"0x110",
")",
";",
"HAL_PCDEx_PMAConfig",
"(",
"(",
"PCD_HandleTypeDef",
"*",
")",
"pdev",
"->",
"pData",
",",
"0x82",
",",
"PCD_SNG_BUF",
",",
"0x100",
")",
";",
"return",
"USBD_OK",
";",
"}"
] | @brief Initializes the Low Level portion of the Device driver. | [
"@brief",
"Initializes",
"the",
"Low",
"Level",
"portion",
"of",
"the",
"Device",
"driver",
"."
] | [
"/* Init USB_IP */",
"/* Link The driver to the stack */"
] | [
{
"param": "pdev",
"type": "USBD_HandleTypeDef"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pdev",
"type": "USBD_HandleTypeDef",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
817bd31d7ac657ba045b68a27b20822b02f3374c | Stoefff/Object-Oriented-Programming-FMI-2017 | Week03/StudentTask/Student.h | [
"MIT"
] | C | readData | void | void readData(char data[], size_t size){
while(cin && isspace(cin.peek()))
cin.ignore();
cin.getline(data, size);
if(cin.fail()){
cin.clear();
while(cin && '\n' != cin.get());
}
cin.clear();
} | //Magic getData, or just save getline for the name | Magic getData, or just save getline for the name | [
"Magic",
"getData",
"or",
"just",
"save",
"getline",
"for",
"the",
"name"
] | void readData(char data[], size_t size){
while(cin && isspace(cin.peek()))
cin.ignore();
cin.getline(data, size);
if(cin.fail()){
cin.clear();
while(cin && '\n' != cin.get());
}
cin.clear();
} | [
"void",
"readData",
"(",
"char",
"data",
"[",
"]",
",",
"size_t",
"size",
")",
"{",
"while",
"(",
"cin",
"&&",
"isspace",
"(",
"cin",
".",
"peek",
"(",
")",
")",
")",
"cin",
".",
"ignore",
"(",
")",
";",
"cin",
".",
"getline",
"(",
"data",
",",
"size",
")",
";",
"if",
"(",
"cin",
".",
"fail",
"(",
")",
")",
"{",
"cin",
".",
"clear",
"(",
")",
";",
"while",
"(",
"cin",
"&&",
"'",
"\\n",
"'",
"!=",
"cin",
".",
"get",
"(",
")",
")",
";",
"}",
"cin",
".",
"clear",
"(",
")",
";",
"}"
] | Magic getData, or just save getline for the name | [
"Magic",
"getData",
"or",
"just",
"save",
"getline",
"for",
"the",
"name"
] | [] | [
{
"param": "data",
"type": "char"
},
{
"param": "size",
"type": "size_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "size",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
acdf20a2e73b8c062bd336076e946812d78558a7 | jcmoyer/moonstorm | src/moonstorm.c | [
"Apache-2.0"
] | C | luaopen_moonstorm | int | int luaopen_moonstorm(lua_State* L) {
ms_init_mpqhandle(L);
ms_init_filehandle(L);
lua_newtable(L);
luaL_setfuncs(L, ms_lib, 0);
return 1;
} | // C linkage required for lua to see this function | C linkage required for lua to see this function | [
"C",
"linkage",
"required",
"for",
"lua",
"to",
"see",
"this",
"function"
] | int luaopen_moonstorm(lua_State* L) {
ms_init_mpqhandle(L);
ms_init_filehandle(L);
lua_newtable(L);
luaL_setfuncs(L, ms_lib, 0);
return 1;
} | [
"int",
"luaopen_moonstorm",
"(",
"lua_State",
"*",
"L",
")",
"{",
"ms_init_mpqhandle",
"(",
"L",
")",
";",
"ms_init_filehandle",
"(",
"L",
")",
";",
"lua_newtable",
"(",
"L",
")",
";",
"luaL_setfuncs",
"(",
"L",
",",
"ms_lib",
",",
"0",
")",
";",
"return",
"1",
";",
"}"
] | C linkage required for lua to see this function | [
"C",
"linkage",
"required",
"for",
"lua",
"to",
"see",
"this",
"function"
] | [] | [
{
"param": "L",
"type": "lua_State"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "L",
"type": "lua_State",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ba5a05b0da0bad63426d406a61a7c17974e3c279 | scorchfly/tpm2-tools | lib/tpm2_eventlog.c | [
"BSD-3-Clause"
] | C | foreach_digest2 | bool | bool foreach_digest2(tpm2_eventlog_context *ctx, unsigned pcr_index, TCG_DIGEST2 const *digest, size_t count, size_t size) {
if (digest == NULL) {
LOG_ERR("digest cannot be NULL");
return false;
}
/* Because pcr_index is used for array indexing and bit-shift operations it
is 1 less than the max value */
if (pcr_index > (TPM2_MAX_PCRS - 1)) {
LOG_ERR("PCR Index %d is out of bounds for max available PCRS %d",
pcr_index, TPM2_MAX_PCRS);
return false;
}
bool ret = true;
size_t i;
for (i = 0; i < count; ++i) {
if (size < sizeof(*digest)) {
LOG_ERR("insufficient size for digest header");
return false;
}
const TPMI_ALG_HASH alg = digest->AlgorithmId;
const size_t alg_size = tpm2_alg_util_get_hash_size(alg);
if (size < sizeof(*digest) + alg_size) {
LOG_ERR("insufficient size for digest buffer");
return false;
}
uint8_t *pcr = NULL;
if (alg == TPM2_ALG_SHA1) {
pcr = ctx->sha1_pcrs[pcr_index];
ctx->sha1_used |= (1 << pcr_index);
} else if (alg == TPM2_ALG_SHA256) {
pcr = ctx->sha256_pcrs[pcr_index];
ctx->sha256_used |= (1 << pcr_index);
} else if (alg == TPM2_ALG_SHA384) {
pcr = ctx->sha384_pcrs[pcr_index];
ctx->sha384_used |= (1 << pcr_index);
} else if (alg == TPM2_ALG_SHA512) {
pcr = ctx->sha512_pcrs[pcr_index];
ctx->sha512_used |= (1 << pcr_index);
} else if (alg == TPM2_ALG_SM3_256) {
pcr = ctx->sm3_256_pcrs[pcr_index];
ctx->sm3_256_used |= (1 << pcr_index);
} else {
LOG_WARN("PCR%d algorithm %d unsupported", pcr_index, alg);
}
if (pcr && !tpm2_openssl_pcr_extend(alg, pcr, digest->Digest, alg_size)) {
LOG_ERR("PCR%d extend failed", pcr_index);
return false;
}
if (ctx->digest2_cb != NULL) {
ret = ctx->digest2_cb(digest, alg_size, ctx->data);
if (!ret) {
LOG_ERR("callback failed for digest at %p with size %zu", digest, alg_size);
break;
}
}
size -= sizeof(*digest) + alg_size;
digest = (TCG_DIGEST2*)((uintptr_t)digest->Digest + alg_size);
}
return ret;
} | /*
* Invoke callback function for each TCG_DIGEST2 structure in the provided
* TCG_EVENT_HEADER2. The callback function is only invoked if this function
* is first able to determine that the provided buffer is large enough to
* hold the digest. The size of the digest is passed to the callback in the
* 'size' parameter.
*/ | Invoke callback function for each TCG_DIGEST2 structure in the provided
TCG_EVENT_HEADER2. The callback function is only invoked if this function
is first able to determine that the provided buffer is large enough to
hold the digest. The size of the digest is passed to the callback in the
'size' parameter. | [
"Invoke",
"callback",
"function",
"for",
"each",
"TCG_DIGEST2",
"structure",
"in",
"the",
"provided",
"TCG_EVENT_HEADER2",
".",
"The",
"callback",
"function",
"is",
"only",
"invoked",
"if",
"this",
"function",
"is",
"first",
"able",
"to",
"determine",
"that",
"the",
"provided",
"buffer",
"is",
"large",
"enough",
"to",
"hold",
"the",
"digest",
".",
"The",
"size",
"of",
"the",
"digest",
"is",
"passed",
"to",
"the",
"callback",
"in",
"the",
"'",
"size",
"'",
"parameter",
"."
] | bool foreach_digest2(tpm2_eventlog_context *ctx, unsigned pcr_index, TCG_DIGEST2 const *digest, size_t count, size_t size) {
if (digest == NULL) {
LOG_ERR("digest cannot be NULL");
return false;
}
if (pcr_index > (TPM2_MAX_PCRS - 1)) {
LOG_ERR("PCR Index %d is out of bounds for max available PCRS %d",
pcr_index, TPM2_MAX_PCRS);
return false;
}
bool ret = true;
size_t i;
for (i = 0; i < count; ++i) {
if (size < sizeof(*digest)) {
LOG_ERR("insufficient size for digest header");
return false;
}
const TPMI_ALG_HASH alg = digest->AlgorithmId;
const size_t alg_size = tpm2_alg_util_get_hash_size(alg);
if (size < sizeof(*digest) + alg_size) {
LOG_ERR("insufficient size for digest buffer");
return false;
}
uint8_t *pcr = NULL;
if (alg == TPM2_ALG_SHA1) {
pcr = ctx->sha1_pcrs[pcr_index];
ctx->sha1_used |= (1 << pcr_index);
} else if (alg == TPM2_ALG_SHA256) {
pcr = ctx->sha256_pcrs[pcr_index];
ctx->sha256_used |= (1 << pcr_index);
} else if (alg == TPM2_ALG_SHA384) {
pcr = ctx->sha384_pcrs[pcr_index];
ctx->sha384_used |= (1 << pcr_index);
} else if (alg == TPM2_ALG_SHA512) {
pcr = ctx->sha512_pcrs[pcr_index];
ctx->sha512_used |= (1 << pcr_index);
} else if (alg == TPM2_ALG_SM3_256) {
pcr = ctx->sm3_256_pcrs[pcr_index];
ctx->sm3_256_used |= (1 << pcr_index);
} else {
LOG_WARN("PCR%d algorithm %d unsupported", pcr_index, alg);
}
if (pcr && !tpm2_openssl_pcr_extend(alg, pcr, digest->Digest, alg_size)) {
LOG_ERR("PCR%d extend failed", pcr_index);
return false;
}
if (ctx->digest2_cb != NULL) {
ret = ctx->digest2_cb(digest, alg_size, ctx->data);
if (!ret) {
LOG_ERR("callback failed for digest at %p with size %zu", digest, alg_size);
break;
}
}
size -= sizeof(*digest) + alg_size;
digest = (TCG_DIGEST2*)((uintptr_t)digest->Digest + alg_size);
}
return ret;
} | [
"bool",
"foreach_digest2",
"(",
"tpm2_eventlog_context",
"*",
"ctx",
",",
"unsigned",
"pcr_index",
",",
"TCG_DIGEST2",
"const",
"*",
"digest",
",",
"size_t",
"count",
",",
"size_t",
"size",
")",
"{",
"if",
"(",
"digest",
"==",
"NULL",
")",
"{",
"LOG_ERR",
"(",
"\"",
"\"",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"pcr_index",
">",
"(",
"TPM2_MAX_PCRS",
"-",
"1",
")",
")",
"{",
"LOG_ERR",
"(",
"\"",
"\"",
",",
"pcr_index",
",",
"TPM2_MAX_PCRS",
")",
";",
"return",
"false",
";",
"}",
"bool",
"ret",
"=",
"true",
";",
"size_t",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"count",
";",
"++",
"i",
")",
"{",
"if",
"(",
"size",
"<",
"sizeof",
"(",
"*",
"digest",
")",
")",
"{",
"LOG_ERR",
"(",
"\"",
"\"",
")",
";",
"return",
"false",
";",
"}",
"const",
"TPMI_ALG_HASH",
"alg",
"=",
"digest",
"->",
"AlgorithmId",
";",
"const",
"size_t",
"alg_size",
"=",
"tpm2_alg_util_get_hash_size",
"(",
"alg",
")",
";",
"if",
"(",
"size",
"<",
"sizeof",
"(",
"*",
"digest",
")",
"+",
"alg_size",
")",
"{",
"LOG_ERR",
"(",
"\"",
"\"",
")",
";",
"return",
"false",
";",
"}",
"uint8_t",
"*",
"pcr",
"=",
"NULL",
";",
"if",
"(",
"alg",
"==",
"TPM2_ALG_SHA1",
")",
"{",
"pcr",
"=",
"ctx",
"->",
"sha1_pcrs",
"[",
"pcr_index",
"]",
";",
"ctx",
"->",
"sha1_used",
"|=",
"(",
"1",
"<<",
"pcr_index",
")",
";",
"}",
"else",
"if",
"(",
"alg",
"==",
"TPM2_ALG_SHA256",
")",
"{",
"pcr",
"=",
"ctx",
"->",
"sha256_pcrs",
"[",
"pcr_index",
"]",
";",
"ctx",
"->",
"sha256_used",
"|=",
"(",
"1",
"<<",
"pcr_index",
")",
";",
"}",
"else",
"if",
"(",
"alg",
"==",
"TPM2_ALG_SHA384",
")",
"{",
"pcr",
"=",
"ctx",
"->",
"sha384_pcrs",
"[",
"pcr_index",
"]",
";",
"ctx",
"->",
"sha384_used",
"|=",
"(",
"1",
"<<",
"pcr_index",
")",
";",
"}",
"else",
"if",
"(",
"alg",
"==",
"TPM2_ALG_SHA512",
")",
"{",
"pcr",
"=",
"ctx",
"->",
"sha512_pcrs",
"[",
"pcr_index",
"]",
";",
"ctx",
"->",
"sha512_used",
"|=",
"(",
"1",
"<<",
"pcr_index",
")",
";",
"}",
"else",
"if",
"(",
"alg",
"==",
"TPM2_ALG_SM3_256",
")",
"{",
"pcr",
"=",
"ctx",
"->",
"sm3_256_pcrs",
"[",
"pcr_index",
"]",
";",
"ctx",
"->",
"sm3_256_used",
"|=",
"(",
"1",
"<<",
"pcr_index",
")",
";",
"}",
"else",
"{",
"LOG_WARN",
"(",
"\"",
"\"",
",",
"pcr_index",
",",
"alg",
")",
";",
"}",
"if",
"(",
"pcr",
"&&",
"!",
"tpm2_openssl_pcr_extend",
"(",
"alg",
",",
"pcr",
",",
"digest",
"->",
"Digest",
",",
"alg_size",
")",
")",
"{",
"LOG_ERR",
"(",
"\"",
"\"",
",",
"pcr_index",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"ctx",
"->",
"digest2_cb",
"!=",
"NULL",
")",
"{",
"ret",
"=",
"ctx",
"->",
"digest2_cb",
"(",
"digest",
",",
"alg_size",
",",
"ctx",
"->",
"data",
")",
";",
"if",
"(",
"!",
"ret",
")",
"{",
"LOG_ERR",
"(",
"\"",
"\"",
",",
"digest",
",",
"alg_size",
")",
";",
"break",
";",
"}",
"}",
"size",
"-=",
"sizeof",
"(",
"*",
"digest",
")",
"+",
"alg_size",
";",
"digest",
"=",
"(",
"TCG_DIGEST2",
"*",
")",
"(",
"(",
"uintptr_t",
")",
"digest",
"->",
"Digest",
"+",
"alg_size",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | Invoke callback function for each TCG_DIGEST2 structure in the provided
TCG_EVENT_HEADER2. | [
"Invoke",
"callback",
"function",
"for",
"each",
"TCG_DIGEST2",
"structure",
"in",
"the",
"provided",
"TCG_EVENT_HEADER2",
"."
] | [
"/* Because pcr_index is used for array indexing and bit-shift operations it\n is 1 less than the max value */"
] | [
{
"param": "ctx",
"type": "tpm2_eventlog_context"
},
{
"param": "pcr_index",
"type": "unsigned"
},
{
"param": "digest",
"type": "TCG_DIGEST2"
},
{
"param": "count",
"type": "size_t"
},
{
"param": "size",
"type": "size_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ctx",
"type": "tpm2_eventlog_context",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pcr_index",
"type": "unsigned",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "digest",
"type": "TCG_DIGEST2",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "count",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "size",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
End of preview. Expand
in Dataset Viewer.
README.md exists but content is empty.
- Downloads last month
- 156