@@ -357,7 +357,8 @@ static cell AMX_NATIVE_CALL F_raise_error(AMX* amx, const cell* params) {
357357 return 0 ;
358358}
359359
360- static const uintptr_t natives[] = { // Indices start at -1000
360+ static const uintptr_t natives[] = {
361+ // Indices start at -1000
361362 (uintptr_t ) lv_label_create,
362363 (uintptr_t ) lv_btn_create,
363364 (uintptr_t ) lv_obj_set_pos,
@@ -366,7 +367,8 @@ static const uintptr_t natives[] = { // Indices start at -1000
366367 (uintptr_t ) lv_obj_realign,
367368};
368369
369- static const AMX_NATIVE lvgl_proxys[] = { // Indices start at -3000
370+ static const AMX_NATIVE lvgl_proxys[] = {
371+ // Indices start at -3000
370372 F_lv_label_create,
371373 F_lv_obj_set_event_cb,
372374 F_lv_label_set_text,
@@ -376,7 +378,8 @@ static const AMX_NATIVE lvgl_proxys[] = { // Indices start at -3000
376378 F_lv_obj_set_style_local_ptr,
377379};
378380
379- static const AMX_NATIVE pawn_proxys[] = { // Indices start at -2000
381+ static const AMX_NATIVE pawn_proxys[] = {
382+ // Indices start at -2000
380383 F_sprintf,
381384 F_read_datetime,
382385 F_read_datetime_short_str,
@@ -501,21 +504,21 @@ int Pawn::LoadProgram() {
501504
502505 memcpy (header, file, hdr.cod );
503506
504- if (hdr.flags & AMX_FLAG_OVERLAY) {
505- datablock = malloc (hdr.stp - hdr.dat ); // This block contains data, heap and stack
506- if (datablock == NULL )
507- return AMX_ERR_MEMORY;
507+ datablock = malloc (hdr.stp - hdr.dat ); // This block contains data, heap and stack
508+ if (datablock == NULL )
509+ return AMX_ERR_MEMORY;
508510
509- memcpy (datablock, file + hdr.dat , hdr.hea - hdr.dat );
511+ memcpy (datablock, file + hdr.dat , hdr.hea - hdr.dat );
512+ amx.data = (unsigned char *) datablock;
510513
514+ if (hdr.flags & AMX_FLAG_OVERLAY) {
511515 constexpr int overlaypool_overhead = 8 ;
512516 overlaypool = malloc (max_overlay_size + overlaypool_overhead);
513517 if (overlaypool == NULL )
514518 return AMX_ERR_MEMORY;
515519
516520 amx_poolinit (&amx_pool, overlaypool, max_overlay_size + overlaypool_overhead);
517521
518- amx.data = (unsigned char *) datablock;
519522 amx.overlay = prun_Overlay;
520523
521524 result = amx_Init (&amx, header);
@@ -528,13 +531,9 @@ int Pawn::LoadProgram() {
528531 overlaypool = NULL ;
529532 }
530533 } else {
531- datablock = malloc (hdr.stp ); // This block contains code, data, heap and stack
532- if (datablock == NULL )
533- return AMX_ERR_MEMORY;
534-
535- memcpy (datablock, file, hdr.size );
534+ amx.flags |= AMX_FLAG_DSEG_INIT;
536535
537- result = amx_Init (&amx, datablock );
536+ result = amx_Init (&amx, ( void *) file );
538537 if (result != AMX_ERR_NONE) {
539538 free (header);
540539 header = NULL ;
0 commit comments