param_export: reduce bson buffer size from 512 to 256

Some modules call this (and maybe in rare circumstances), which could lead
to stack overflows. With our current headroom of >= 300bytes, 256 should
be ok.

This increases the export time from ~28ms to ~34ms in my case (on a
Pixracer)
This commit is contained in:
Beat Küng 2018-01-10 20:40:58 +01:00
parent ee9853a3d6
commit f962e9826b
2 changed files with 3 additions and 1 deletions

View File

@ -1048,7 +1048,7 @@ param_export(int fd, bool only_unsaved)
param_lock_reader();
uint8_t bson_buffer[512];
uint8_t bson_buffer[256];
bson_encoder_init_buf(&encoder, &bson_buffer, sizeof(bson_buffer));
/* no modified parameters -> we are done */

View File

@ -299,6 +299,7 @@ __EXPORT void param_reset_excludes(const char *excludes[], int num_excludes);
/**
* Export changed parameters to a file.
* Note: this method requires a large amount of stack size!
*
* @param fd File descriptor to export to.
* @param only_unsaved Only export changed parameters that have not yet been exported.
@ -365,6 +366,7 @@ __EXPORT const char *param_get_default_file(void);
/**
* Save parameters to the default file.
* Note: this method requires a large amount of stack size!
*
* This function saves all parameters with non-default values.
*