Levi Neely
5dd299c499
Make 18 internal functions static ( #387 )
...
- pcryptofolder.c: psync_cloud_crypto_send_mkdir, psync_pcloud_crypto_reencode_key, psync_pcloud_crypto_encode_key
- psynclib.c: psync_set_ssl_debug_callback, psync_reset_apiserver, create_bup_mach_folder, psync_async_delete_sync
- pfscrypto.c: pfs_crpt_write_mod_nu
- ppagecache.c: clean_cache_del
- publiclinks.c: process_bres, do_delete_all_links
- pfsupload.c: upload_modify
- debug/pnetlibs_debug.c: pident
- pnetlibs.c: psync_socket_close_download
- pfstasks.c: pfs_task_stop_and_delete_file
- pssl.c: rng_get
- pupload.c: handle_api_errors
Co-authored-by: Levi Neely <lkn@darkstar.example.net>
2026-03-11 21:25:14 +01:00
Levi Neely
358ae595e9
Add memory accounting per subsystem ( #371 )
...
* Implement memory accounting infrastructure
* Migrate malloc/calloc to pmem_malloc with subsystem tracking
* Add overflow-safe pmem_malloc_array function
* Migrate pfstasks.c malloc/free to pmem_malloc/pmem_free
* Migrate pnetlibs.c malloc/free to pmem_malloc/pmem_free
* Fix multiplication patterns in pnetlibs.c with pmem_malloc_array
* Migrate ppagecache.c malloc/free to pmem_malloc/pmem_free
* Fix remaining multiplication pattern in ppagecache.c line 3239
* Migrate pssl.c malloc/free to pmem_malloc/pmem_free
* Migrate pcryptofolder.c malloc/free to pmem_malloc/pmem_free
* Migrate pfolder.c malloc/free to pmem_malloc/pmem_free
* Fix multiplication patterns in pfolder.c with overflow checks
* Migrate publiclinks.c malloc/free to pmem_malloc/pmem_free
* Migrate plocalscan.c malloc/free to pmem_malloc/pmem_free
* Migrate psql.c malloc/free to pmem_malloc/pmem_free
* Migrate putil.c malloc/free to pmem_malloc/pmem_free
* Fix multiplication patterns in putil.c encoding functions with overflow checks
* Migrate pfsupload.c malloc/free to pmem_malloc/pmem_free
* Migrate pdiff.c malloc/free to pmem_malloc/pmem_free
* Migrate pcrypto.c malloc/free to pmem_malloc/pmem_free
* Migrate pupload.c malloc/free to pmem_malloc/pmem_free
* Migrate psock.c malloc/free to pmem_malloc/pmem_free
* Fix multiplication pattern in psock.c with overflow checks
* Add panic() with backtrace to psignal module
* Register panic handlers early in main()
* Fix panic() infinite recursion by unregistering handlers before abort()
* Migrate remaining 34 files to pmem_malloc/pmem_free
* Migrate papi.c, ptools.c, pbusinessaccount.c to PMEM_SUBSYS_API
* Fix pcache.c compilation errors - replace he->pmem_free with pmem_free
* Add pmem.h include to pdbg.c
* Add pmem.h include to 10 files missing it
* Fix ptask.c compilation errors - replace s->pmem_free with s->free
* Fix ptask.c callback arguments - remove PMEM_SUBSYS_OTHER from s->free calls
* Fix pmem.c infinite recursion - use raw malloc/free internally
* Fix prand.c mixed allocation - use pmem_free for putil_strdup result
* Migrate psettings.c free() calls to pmem_free()
* Fix all remaining stray free() calls - migrate to pmem_free()
* Fix pnetlibs_debug.c free() call - migrate to pmem_free()
* Add missing pmem.h include to pdevice.c
* Migrate pclsync_lib.cpp free() calls to pmem_free()
* Fix pfolder.c psync_free_string_list to use pmem_free()
* Fix all psync_list_for_each_element_call to use pmem_free wrappers
* Fix all list free wrapper functions - add proper definitions
* Fix rpcclient.cpp mixed allocation - use pmem_free for prpc_sockpath
* Replace all realloc() calls with pmem_realloc()
* Replace all strdup() calls with putil_strdup()
* Fix rpcclient.cpp allocation boundary - use plain malloc/free for RPC responses
* Fix RPC response length calculation - include header size
* Fix control_tools.cpp mixed allocations - use pmem_free for pshm_read results
---------
Co-authored-by: Levi Neely <lkn@darkstar.example.net>
2026-03-08 21:47:22 +01:00
Levi Neely
61259858c8
Fix debug build segfault: add strong overrides for psql_lock/unlock functions ( #177 )
...
The weak/strong symbol approach requires that psql.c undefs the debug
macros to define function implementations. This means functions in psql.c
call psql_lock()/psql_unlock() as functions, not macros.
In debug builds, these must be strong overrides that call the _do_
variants to properly maintain lockctr/rdlockctr. Without these overrides,
the weak stubs are used which don't update counters, causing assertion
failures in psql_unlock().
Added strong overrides in psql_debug.c for:
- psql_lock() -> psql_do_lock(__FILE__, __LINE__)
- psql_rdlock() -> psql_do_rdlock(__FILE__, __LINE__)
- psql_statement() (calls psql_do_lock directly)
Also made psql_statement, psql_start, and all query/prepare functions
weak in psql.c to allow debug overrides.
Fixes #138
Co-authored-by: Levi Neely <lkn@darkstar.example.net>
2026-03-03 07:59:30 +01:00