Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.
This repository was archived by the owner on Oct 8, 2025. It is now read-only.

Duplicated strings, and arrays of pointers #720

@alejandro-colomar

Description

@alejandro-colomar
$ grep -rnA1 '"Mar"'
src/nxt_router.c:3824:    static const char  *month[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
src/nxt_router.c-3825-                                    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
--
src/nxt_controller.c:2135:    static const char  *month[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
src/nxt_controller.c-2136-                                    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
--
src/nxt_http.h:293:    static const char  *month[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
src/nxt_http.h-294-                                    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };

We have duplicated strings for the months. Maybe this same thing happens with other code; I should check.

Also, we could optimize this based on Ulrich Drepper's How To Write Shared Libraries paper into:

const char nxt_month[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
                              "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };

Check https://www.akkadia.org/drepper/dsohowto.pdf 2.4.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions