view src/dmresw.c @ 1785:86d10d5d4915

Fix case where DMGrowBuf is growing backwards and needs to be reallocated in dmGrowBufRealloc() and the data is moved to the "end" of the newly grown buffer. Previously we used clrsize as data size, but that is (in retrospect) obviously incorrect. Use old buffer size instead.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 13 Jun 2018 01:39:06 +0300
parents 0cac3360a0aa
children 73545a442ffe
line wrap: on
line source

/*
 * DMLib
 * -- Resource management
 * Programmed and designed by Matti 'ccr' Hamalainen
 * (C) Copyright 2011-2015 Tecnic Software productions (TNSP)
 */
#include "dmresw.h"


BOOL dmf_write_str(DMResource *fh, const void *data, const size_t len)
{
    return dmfwrite(data, len, 1, fh) == 1;
}


BOOL dmf_write_byte(DMResource *fh, const Uint8 val)
{
    return dmfputc(val, fh) == val;
}


#define DM_DEFINE_FFUNC(xname, xtype, xmacro)            \
BOOL dmf_write_ ## xname (DMResource *f, const xtype v) {     \
    xtype result = DM_NATIVE_TO_ ## xmacro (v);         \
    if (dmfwrite(&result, sizeof( xtype ), 1, f) != 1)  \
        return FALSE;                                   \
    return TRUE;                                        \
}

#include "dmfiletmpl.h"

#undef DM_DEFINE_FFUNC