• [^] # Re: libapr

    Posté par . En réponse au message aspritnf et realloc. Évalué à 3.

    man asprintf

    -> The printf() family of functions produces output according to a format as
    described below. The printf() and vprintf() functions write output to
    stdout, the standard output stream; fprintf() and vfprintf() write output
    to the given output stream; sprintf(), snprintf(), vsprintf(), and
    vsnprintf() write to the character string str; and asprintf() and
    vasprintf() dynamically allocate a new string with malloc(3)

    Il y aura dond réallocation (dynamically allocate a new string with malloc) mais le problème est surtout de savoir si buffer pointera sur le nouvel espace mémoire avant d'avoir traduit le %s ou après ?
    En tout cas, il me semble dangereux (dans la mesure où l'on ne connais pas la réponse à la question ci-dessus) d'utiliser le même pointeur pour la chaîne à lire et pour la nouvelle chaîne