Mtk platform summarize
1. global variable use
1.1 assure one application one entry and one exit function, so the memory can easily manager
1.2 one application has one global struct (cconv_context_struct *g_cconv_cntx = NULL;), once malloc and once free, not waste time, and also avoid too many global variable
1.3 because the stack is limits to 2k, so you can define the big array in the struct, it can be convenience
1.4 you can define the data which you must use in the application in the struct, so your application do not need to define other data, it is convenience
1.5 avoid some frequent occurring memory problem
1.6 you must add as prefix *g_snmp_cntx before your global variable, it mean a global module context pointer
1.7 you need add comment after each member of the struct, so the program can be easily understood by others
1.8 you must assign it to null in your definition (*g_cconv_cntx = NULL;), so to avoid other people use is before malloc it
2. code file manager
2.1 in header(.h) file
2.1.1 /* Define (void)*/
2.1.2 /* Typedef (enum) */
2.1.3 /* Extern Global Variable (void) */
2.1.4 /* Extern Global Function (export) */
2.2 In implement(.c) file
2.2.1 /* Include: MMI header file */
2.2.2 /* Define (app local define)*/
2.2.3 /* Typedef (global struct) */
2.2.4 /* Local Variable (void) */
2.2.5 /* Local Function (declare) */
2.2.6 /* Global Variable (local and extern) */
2.2.7 /* Global Function (extern)*/
2.2.8 /* local function implement */
3. header file
3.1 eg.
#ifndef _MMI_CURRENCYCONV_H
#define _MMI_CURRENCYCONV_H
#include "MMI_features.h"
#ifdef __MMI_EXTENDED_CURRENCY_CONVERTER__
#include "PixtelDataTypes.h"
3.2 #ifndef #define to avoid redefine header file
3.3 #include "MMI_features.h" to include feature of the project
3.4 #ifdef __MMI_EXTENDED_CURRENCY_CONVERTER__ to control if this app code should be compiled to reduce the project code weight
3.5 #include "PixtelDataTypes.h" to define common data type
4. file manager
When you open a file, you must close it after use, if you do not do that, it will be memory leak, after about 10 – 30 times the functions executing, the memory overflow, and the mobile reboot.
Open (&file) && Close (&file) must match